internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pandas-dev/pandas

Issue:
DOC: .nlargest/smallest docs specify keep=False as valid parameter
For both DataFrame and Series docs:

> keep : {‘first’, ‘last’, False}, default ‘first’
Where there are duplicate values: - first : take the first occurrence. - last : take the last occurrence.

```
In [2]: pd.Series(range(5)).nlargest(3, keep=False)

ValueError: keep must be either "first", "last"

In [3]: pd.DataFrame(range(5)).nsmallest(3,  0, keep=False)

ValueError: keep must be either "first", "last"
```


Discussion:
hmm, yeah that seems old.

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -3769,7 +3769,7 @@ def nlargest(self, n, columns, keep='first'):
             Number of items to retrieve
         columns : list or str
             Column name or names to order by
-        keep : {'first', 'last', False}, default 'first'
+        keep : {'first', 'last'}, default 'first'
             Where there are duplicate values:
             - ``first`` : take the first occurrence.
             - ``last`` : take the last occurrence.
@@ -3804,7 +3804,7 @@ def nsmallest(self, n, columns, keep='first'):
             Number of items to retrieve
         columns : list or str
             Column name or names to order by
-        keep : {'first', 'last', False}, default 'first'
+        keep : {'first', 'last'}, default 'first'
             Where there are duplicate values:
             - ``first`` : take the first occurrence.
             - ``last`` : take the last occurrence.
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -2058,7 +2058,7 @@ def nlargest(self, n=5, keep='first'):
         ----------
         n : int
             Return this many descending sorted values
-        keep : {'first', 'last', False}, default 'first'
+        keep : {'first', 'last'}, default 'first'
             Where there are duplicate values:
             - ``first`` : take the first occurrence.
             - ``last`` : take the last occurrence.
@@ -2105,7 +2105,7 @@ def nsmallest(self, n=5, keep='first'):
         ----------
         n : int
             Return this many ascending sorted values
-        keep : {'first', 'last', False}, default 'first'
+        keep : {'first', 'last'}, default 'first'
             Where there are duplicate values:
             - ``first`` : take the first occurrence.
             - ``last`` : take the last occurrence.


Test patch:
Repository: pandas-dev/pandas

Issue:
BLD: Bump Cython version from 0.23 to 0.24
Per https://github.com/pandas-dev/pandas/pull/18602#discussion_r154537313, version 0.23 does not fully support using `@property` syntax, so we could use this as an opportunity to bump to version 0.24.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ def is_platform_mac():
     return sys.platform == 'darwin'
 
 
-min_cython_ver = '0.23'
+min_cython_ver = '0.24'
 try:
     import Cython
     ver = Cython.__version__


Test patch:
Repository: pandas-dev/pandas

Issue:
ENH: Make corrwith ignore string columns when finding correlation with a Series
#### Code Sample, a copy-pastable example if possible

```python
>>> df = pd.DataFrame({'a':np.random.rand(5), 
                   'b':np.random.rand(5),
                  'string_col':'some string'})
>>> df

          a         b   string_col
0  0.376004  0.761471  some string
1  0.402352  0.865937  some string
2  0.450365  0.715527  some string
3  0.445317  0.017645  some string
4  0.687363  0.903298  some string

>>> s = pd.Series(np.random.rand(100))

>>> df.corrwith(s)
TypeError: ("unsupported operand type(s) for /: 'str' and 'int'", 'occurred at index string_col')

```
#### Problem description

Pandas should silently drop the string columns. For now, you must do this:

#### Expected Output
```
>>> df.select_dtypes('number').corrwith(s)
a    0.161006
b   -0.000233
dtype: float64
```



Discussion:
@tdpetrou : Thanks for reporting this!  While your workaround isn't that hard to do, I don't see why we shouldn't just drop columns that have non-numeric `dtypes`.  We do that for `DataFrame.describe`.

@jreback @jorisvandenbossche : Thoughts?
sure this could be done, ``.corrwith`` is a numeric only operation. Would take a community pull request.

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -5577,7 +5577,7 @@ def corrwith(self, other, axis=0, drop=False):
 
         Parameters
         ----------
-        other : DataFrame
+        other : DataFrame, Series
         axis : {0 or 'index', 1 or 'columns'}, default 0
             0 or 'index' to compute column-wise, 1 or 'columns' for row-wise
         drop : boolean, default False
@@ -5588,10 +5588,11 @@ def corrwith(self, other, axis=0, drop=False):
         correls : Series
         """
         axis = self._get_axis_number(axis)
+        this = self._get_numeric_data()
+
         if isinstance(other, Series):
-            return self.apply(other.corr, axis=axis)
+            return this.apply(other.corr, axis=axis)
 
-        this = self._get_numeric_data()
         other = other._get_numeric_data()
 
         left, right = this.align(other, join='inner', copy=False)


Test patch:
diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py
--- a/pandas/tests/frame/test_analytics.py
+++ b/pandas/tests/frame/test_analytics.py
@@ -240,6 +240,16 @@ def test_corrwith_matches_corrcoef(self):
         tm.assert_almost_equal(c1, c2)
         assert c1 < 1
 
+    def test_corrwith_mixed_dtypes(self):
+        # GH 18570
+        df = pd.DataFrame({'a': [1, 4, 3, 2], 'b': [4, 6, 7, 3],
+                           'c': ['a', 'b', 'c', 'd']})
+        s = pd.Series([0, 6, 7, 3])
+        result = df.corrwith(s)
+        corrs = [df['a'].corr(s), df['b'].corr(s)]
+        expected = pd.Series(data=corrs, index=['a', 'b'])
+        tm.assert_series_equal(result, expected)
+
     def test_bool_describe_in_mixed_frame(self):
         df = DataFrame({
             'string_data': ['a', 'b', 'c', 'd', 'e'],
Repository: pandas-dev/pandas

Issue:
Minor documentation issue on pd.DataFrame.last_valid_index()
Documentation says "first" on both first and last methods

![image](https://user-images.githubusercontent.com/9113853/33384362-f526c1b6-d50c-11e7-97b1-61b8c310301f.png)

![image](https://user-images.githubusercontent.com/9113853/33384382-04d2738a-d50d-11e7-93ac-5c76d3ff1d23.png)

Pandas version = 0.21.0


Discussion:
first -> last here: https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L4317


can you do a PR?
I've never done one but I will happily learn how to tonight

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -4320,7 +4320,7 @@ def first_valid_index(self):
         return valid_indices[0] if len(valid_indices) else None
 
     @Appender(_shared_docs['valid_index'] % {
-        'position': 'first', 'klass': 'DataFrame'})
+        'position': 'last', 'klass': 'DataFrame'})
     def last_valid_index(self):
         if len(self) == 0:
             return None


Test patch:
Repository: pandas-dev/pandas

Issue:
broken timestamp asvs
@mroeschke do these indicate incorrectly written benchmarks?

```
asv continuous -f 1.1 -E virtualenv master HEAD -b timeseries -b timestamp -b timedelta -b period -b offset
[...]
[  1.86%] ··· Running gil.nogil_datetime_fields.time_period_to_datetime                          failed
[  2.13%] ··· Running indexing.AssignTimeseriesIndex.time_frame_assign_timeseries_index          failed
[...]
[ 45.48%] ··· Running timestamp.TimestampProperties.time_dayofweek                               failed
[ 45.74%] ··· Running timestamp.TimestampProperties.time_dayofyear                               failed
[ 46.01%] ··· Running timestamp.TimestampProperties.time_days_in_month                           failed
[ 46.28%] ··· Running timestamp.TimestampProperties.time_freqstr                                 failed
[ 46.54%] ··· Running timestamp.TimestampProperties.time_is_leap_year                            failed
[ 46.81%] ··· Running timestamp.TimestampProperties.time_is_month_end                            failed
[ 47.07%] ··· Running timestamp.TimestampProperties.time_is_month_start                          failed
[ 47.34%] ··· Running timestamp.TimestampProperties.time_is_quarter_end                          failed
[ 47.61%] ··· Running timestamp.TimestampProperties.time_is_quarter_start                        failed
[ 47.87%] ··· Running timestamp.TimestampProperties.time_is_year_end                             failed
[ 48.14%] ··· Running timestamp.TimestampProperties.time_is_year_start                           failed
[ 48.40%] ··· Running timestamp.TimestampProperties.time_microsecond                             failed
[ 48.67%] ··· Running timestamp.TimestampProperties.time_offset                                  failed
[ 48.94%] ··· Running timestamp.TimestampProperties.time_quarter                                 failed
[ 49.20%] ··· Running timestamp.TimestampProperties.time_tz                                      failed
[ 49.47%] ··· Running timestamp.TimestampProperties.time_week                                    failed
[ 49.73%] ··· Running timestamp.TimestampProperties.time_weekday_name                            failed
```


Discussion:
Possibly. `asv dev -b timeseries -b timestamp -b timedelta -b period -b offset` will return tracebacks if the benchmarks have any errors. 

The annoying thing is that sometimes `asv dev` will say the benchmarks are okay but `asv run` or `asv continuous ` will still say "failed", not completely sure why...

Resolving patch:
diff --git a/asv_bench/benchmarks/timestamp.py b/asv_bench/benchmarks/timestamp.py
--- a/asv_bench/benchmarks/timestamp.py
+++ b/asv_bench/benchmarks/timestamp.py
@@ -6,10 +6,9 @@
 class TimestampProperties(object):
     goal_time = 0.2
 
-    params = [(None, None),
-              (pytz.timezone('Europe/Amsterdam'), None),
-              (None, 'B'),
-              (pytz.timezone('Europe/Amsterdam'), 'B')]
+    _tzs = [None, pytz.timezone('Europe/Amsterdam')]
+    _freqs = [None, 'B']
+    params = [_tzs, _freqs]
     param_names = ['tz', 'freq']
 
     def setup(self, tz, freq):


Test patch:
Repository: pandas-dev/pandas

Issue:
read_csv() usecols behavior unclear
#### Code Sample, a copy-pastable example if possible

```python
                     names= ['Date', 'CreamSupply', 'RawMilk', 'Protein', 'FatProtein', 'MilkFilterInlet' #...... 
],
usecols=
 [0,132,52,19,18,133,71,70,158,92,93,94,156,157,134,135,89,73,72,27,25,24,54,53,75,74,136]

```
#### Problem description

One would think that usecols would allow a user to select the columns (and due to the fact that it's a list), the order of the columns. Either this feature disrespects the order (bug) or it is intended and the documentation should reflect that.


Latest version.


Discussion:
Thought we had an open issue about this, but I can't find it.  Yes, at the moment `usecols` is set-like, would definitely take a documentation PR to make this clearer
Hey, I'd be happy to update the docs and make this clearer?

Long time Pandas user, just wanted to start contributing back.
I would be happy to do it as well if I knew how. I haven't committed yet.

On Fri, Dec 8, 2017 at 1:53 PM, evanmiller29 <notifications@github.com>
wrote:

> Hey, I'd be happy to update the docs and make this clearer?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/issues/18673#issuecomment-350342537>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ARpyctH9C9Kfvyak8EjVKhCDDkos9O1Nks5s-YWjgaJpZM4Q4usV>
> .
>


Resolving patch:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -101,7 +101,8 @@
     be positional (i.e. integer indices into the document columns) or strings
     that correspond to column names provided either by the user in `names` or
     inferred from the document header row(s). For example, a valid array-like
-    `usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz'].
+    `usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']. Element
+    order is ignored, so usecols=[1,0] is the same as [0,1].
 
     If callable, the callable function will be evaluated against the column
     names, returning names where the callable function evaluates to True. An


Test patch:
Repository: pandas-dev/pandas

Issue:
DOC: add examples to docstrings
This often used functions lacks some illustrating examples

- [x] ``sort_values`` (#16437)
- [x] ``reset_values`` (#16967)
- [x] ``set_index`` (#16467)
- [x] ``fillna`` (#16437)
- [x] ``drop`` (#16437)
- [x] ``pop`` (#16520)


Discussion:
Other docstrings that are in the top most viewed and lacking examples: `reset_index`, `set_index`, `fillna`, `drop`
@jorisvandenbossche I'd like to take this one. 
@geoninja any chance you're at Pycon doing sprints right now?
I can add some examples for `fillna` and `drop`.
@jorisvandenbossche Both Vincent and I are at PyCon so we will split the work on this one
I'm going to work on reset_values so we can close this issue.
if anyone at sprints wants to add to ``.reset_index()`` we can close this one

@TomAugspurger 
I'm working on .reset_index() example.

Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -3563,6 +3563,44 @@ def head(self, n=5):
         -------
         obj_head : type of caller
             The first n rows of the caller object.
+
+        See Also
+        --------
+        pandas.DataFrame.tail
+
+        Examples
+        --------
+        >>> df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
+        ...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
+        >>> df
+              animal
+        0  alligator
+        1        bee
+        2     falcon
+        3       lion
+        4     monkey
+        5     parrot
+        6      shark
+        7      whale
+        8      zebra
+
+        Viewing the first 5 lines
+
+        >>> df.head()
+              animal
+        0  alligator
+        1        bee
+        2     falcon
+        3       lion
+        4     monkey
+
+        Viewing the first n lines (three in this case)
+
+        >>> df.head(3)
+              animal
+        0  alligator
+        1        bee
+        2     falcon
         """
 
         return self.iloc[:n]
@@ -3580,6 +3618,44 @@ def tail(self, n=5):
         -------
         obj_tail : type of caller
             The last n rows of the caller object.
+
+        See Also
+        --------
+        pandas.DataFrame.head
+
+        Examples
+        --------
+        >>> df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
+        ...                    'monkey', 'parrot', 'shark', 'whale', 'zebra']})
+        >>> df
+              animal
+        0  alligator
+        1        bee
+        2     falcon
+        3       lion
+        4     monkey
+        5     parrot
+        6      shark
+        7      whale
+        8      zebra
+
+        Viewing the last 5 lines
+
+        >>> df.tail()
+           animal
+        4  monkey
+        5  parrot
+        6   shark
+        7   whale
+        8   zebra
+
+        Viewing the last n lines (three in this case)
+
+        >>> df.tail(3)
+          animal
+        6  shark
+        7  whale
+        8  zebra
         """
 
         if n == 0:


Test patch:
Repository: pandas-dev/pandas

Issue:
Groupby missing tuple doesn't throw
#### Code Sample, a copy-pastable example if possible

```python
import pandas as pd
df = pd.DataFrame(1, index=range(3), columns=pd.MultiIndex.from_product([[1, 2], [3,4]]))
df.groupby((7, 8)).mean()
```

In 0.20.3 that raised `KeyError: 7`

On master I get

```python
Out[4]:
   1     2
   3  4  3  4
7  1  1  1  1
8  1  1  1  1

```

cc @toobaz 


Discussion:

Resolving patch:
diff --git a/pandas/core/groupby.py b/pandas/core/groupby.py
--- a/pandas/core/groupby.py
+++ b/pandas/core/groupby.py
@@ -2977,7 +2977,7 @@ def is_in_obj(gpr):
 
 
 def _is_label_like(val):
-    return (isinstance(val, compat.string_types) or
+    return (isinstance(val, (compat.string_types, tuple)) or
             (val is not None and is_scalar(val)))
 
 


Test patch:
diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py
--- a/pandas/tests/groupby/test_groupby.py
+++ b/pandas/tests/groupby/test_groupby.py
@@ -2750,7 +2750,6 @@ def test_tuple_warns_unhashable(self):
 
         assert "Interpreting tuple 'by' as a list" in str(w[0].message)
 
-    @pytest.mark.xfail(reason="GH-18798")
     def test_tuple_correct_keyerror(self):
         # https://github.com/pandas-dev/pandas/issues/18798
         df = pd.DataFrame(1, index=range(3),
Repository: pandas-dev/pandas

Issue:
BUG: insert NaT into tz-aware DTI.
this should work (also should test for other index reshaping ops) & for TDI and PI
```
In [7]: pd.DatetimeIndex(['2017-01-01']).insert(0, pd.NaT)
Out[7]: DatetimeIndex(['NaT', '2017-01-01'], dtype='datetime64[ns]', freq=None)

In [8]: pd.DatetimeIndex(['2017-01-01'], tz='UTC').insert(0, pd.NaT)
ValueError: Passed item and index have different timezone
```


Discussion:
Taking a look at this

Resolving patch:
diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py
--- a/pandas/core/indexes/datetimes.py
+++ b/pandas/core/indexes/datetimes.py
@@ -1775,7 +1775,7 @@ def insert(self, loc, item):
 
         if isinstance(item, (datetime, np.datetime64)):
             self._assert_can_do_op(item)
-            if not self._has_same_tz(item):
+            if not self._has_same_tz(item) and not isna(item):
                 raise ValueError(
                     'Passed item and index have different timezone')
             # check freq can be preserved on edge cases


Test patch:
diff --git a/pandas/tests/indexes/datetimes/test_indexing.py b/pandas/tests/indexes/datetimes/test_indexing.py
--- a/pandas/tests/indexes/datetimes/test_indexing.py
+++ b/pandas/tests/indexes/datetimes/test_indexing.py
@@ -46,6 +46,15 @@ def test_where_tz(self):
         expected = i2
         tm.assert_index_equal(result, expected)
 
+    @pytest.mark.parametrize('null', [None, np.nan, pd.NaT])
+    @pytest.mark.parametrize('tz', [None, 'UTC', 'US/Eastern'])
+    def test_insert_nat(self, tz, null):
+        # GH#16537, GH#18295 (test missing)
+        idx = pd.DatetimeIndex(['2017-01-01'], tz=tz)
+        expected = pd.DatetimeIndex(['NaT', '2017-01-01'], tz=tz)
+        res = idx.insert(0, null)
+        tm.assert_index_equal(res, expected)
+
     def test_insert(self):
         idx = DatetimeIndex(
             ['2000-01-04', '2000-01-01', '2000-01-02'], name='idx')
@@ -145,13 +154,6 @@ def test_insert(self):
                 assert result.tz == expected.tz
                 assert result.freq is None
 
-        # GH 18295 (test missing)
-        expected = DatetimeIndex(
-            ['20170101', pd.NaT, '20170102', '20170103', '20170104'])
-        for na in (np.nan, pd.NaT, None):
-            result = date_range('20170101', periods=4).insert(1, na)
-            tm.assert_index_equal(result, expected)
-
     def test_delete(self):
         idx = date_range(start='2000-01-01', periods=5, freq='M', name='idx')
Repository: pandas-dev/pandas

Issue:
Remove to_long and toLong, deprecated in 0.7.0
Those `Panel` methods were deprecated in December 2011, before Pandas 0.7.0 was released [1]. Probably because they used the `deprecate`decorator, they weren't spotted before, and they weren't added to #6581. So, they are still available, even if they had to be removed in Pandas 0.10.0.

1. https://github.com/pandas-dev/pandas/commit/fae6272607d4e0787a2e5476b5401144473dfced


Discussion:

Resolving patch:
diff --git a/pandas/core/panel.py b/pandas/core/panel.py
--- a/pandas/core/panel.py
+++ b/pandas/core/panel.py
@@ -996,9 +996,6 @@ def construct_index_parts(idx, major=True):
 
         return DataFrame(data, index=index, columns=self.items)
 
-    to_long = deprecate('to_long', to_frame)
-    toLong = deprecate('toLong', to_frame)
-
     def apply(self, func, axis='major', **kwargs):
         """
         Applies function along axis (or axes) of the Panel


Test patch:
Repository: pandas-dev/pandas

Issue:
FutureWarning for .loc[list-of-labels] with missing labels provides wrong URL
#### Code Sample, a copy-pastable example if possible

```
In [2]: s = pd.Series(['foo', 'bar', 'baz'])

In [3]: s.loc[[2,3]]
FutureWarning:
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.

See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike
  if __name__ == '__main__':
Out[3]:
2    baz
3    NaN
dtype: object
```
#### Problem description
The URL in the deprecation warning has the wrong section name (#deprecate-loc-reindex-listlike), so the user isn't redirected to the relevant section.

#### Expected Output
I'd expect the URL to be link to have the correct section name (#indexing-deprecate-loc-reindex-listlike) or change the section name so it matches the link.

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: 78147e9c84fb55a67af382a2d3a090e6b0828532
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.0.dev0+81.g78147e9
pytest: 3.1.2
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.13.3
scipy: 1.0.0
pyarrow: 0.6.0
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: None
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: 0.1.0
pandas_gbq: None
pandas_datareader: None

</details>

  


Discussion:

Resolving patch:
diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py
--- a/pandas/core/indexing.py
+++ b/pandas/core/indexing.py
@@ -1479,7 +1479,7 @@ def _has_valid_type(self, key, axis):
                         KeyError in the future, you can use .reindex() as an alternative.
 
                         See the documentation here:
-                        http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike""")  # noqa
+                        https://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike""")  # noqa
 
                         if not (ax.is_categorical() or ax.is_interval()):
                             warnings.warn(_missing_key_warning,


Test patch: