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

Issue:
BUG: to_timedelta('NaT', box=False) returns datetime64('NaT')
On pandas 0.23 (correct):
```
In [2]: pd.to_timedelta('NaT', box=False)
Out[2]: numpy.timedelta64('NaT','ns')
```

But on pandas 0.24:
```
In [2]: pd.to_timedelta('NaT', box=False)
Out[2]: numpy.datetime64('NaT')
```

The result is a datetime, not a timedelta.


Discussion:
looks like a bug; note that box parameter is going away in any event
> looks like a bug; note that box parameter is going away in any event

I hope there's a deprecation cycle planned? (We use `box` downstream in xarray.)
yes there is an issue about this
xref #24416
I’m pretty sure one of my recent PRs broke this, will make a fix shortly.

Resolving patch:
diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py
--- a/pandas/core/tools/timedeltas.py
+++ b/pandas/core/tools/timedeltas.py
@@ -120,7 +120,8 @@ def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'):
     try:
         result = Timedelta(r, unit)
         if not box:
-            result = result.asm8
+            # explicitly view as timedelta64 for case when result is pd.NaT
+            result = result.asm8.view('timedelta64[ns]')
     except ValueError:
         if errors == 'raise':
             raise


Test patch:
diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py
--- a/pandas/tests/scalar/timedelta/test_timedelta.py
+++ b/pandas/tests/scalar/timedelta/test_timedelta.py
@@ -309,8 +309,13 @@ def test_iso_conversion(self):
         assert to_timedelta('P0DT0H0M1S') == expected
 
     def test_nat_converters(self):
-        assert to_timedelta('nat', box=False).astype('int64') == iNaT
-        assert to_timedelta('nan', box=False).astype('int64') == iNaT
+        result = to_timedelta('nat', box=False)
+        assert result.dtype.kind == 'm'
+        assert result.astype('int64') == iNaT
+
+        result = to_timedelta('nan', box=False)
+        assert result.dtype.kind == 'm'
+        assert result.astype('int64') == iNaT
 
     @pytest.mark.parametrize('units, np_unit',
                              [(['Y', 'y'], 'Y'),
Repository: pandas-dev/pandas

Issue:
Excluding validation error type `PR10` from code base
#### Problem description

In order to have a continuous check by the CI on validation error `PR10`, tackling them from the current code base enables the addition to the CI for automated testing in the future.

After checking an [overview of the errors](https://gist.github.com/stijnvanhoey/dfec0f89a58f493bdddd2b463ad7b6e3) (all credits to @datapythonista for the introduction during europandas sprint), the `PR10` has just 3 occurrences, so tackling them should be feasible during the sprint.

|                                              |   deprecated | section                          | type               |
|:---------------------------------------------|-------------:|:---------------------------------|:-------------------|
| pandas.set_option                            |            0 | Working with options             | CallableDynamicDoc |
| pandas.ExcelWriter                           |            0 |                                  | ABCMeta            |
| pandas.core.groupby.DataFrameGroupBy.boxplot |            0 | Computations / Descriptive Stats | function           |

Todo:
* [ ] get rid of the errors in the code base
* [ ] update the `code_check.sh` script to take into account the `PR10` type of errors



Discussion:
I'll take it

Resolving patch:
diff --git a/pandas/core/config.py b/pandas/core/config.py
--- a/pandas/core/config.py
+++ b/pandas/core/config.py
@@ -282,8 +282,8 @@ def __doc__(self):
     Note: partial matches are supported for convenience, but unless you use the
     full option name (e.g. x.y.z.option_name), your code may break in future
     versions if new options with similar names are introduced.
-value :
-    new value of option.
+value : object
+    New value of option.
 
 Returns
 -------
diff --git a/pandas/io/excel.py b/pandas/io/excel.py
--- a/pandas/io/excel.py
+++ b/pandas/io/excel.py
@@ -1003,7 +1003,7 @@ class ExcelWriter(object):
     mode : {'w' or 'a'}, default 'w'
         File mode to use (write or append).
 
-    .. versionadded:: 0.24.0
+        .. versionadded:: 0.24.0
 
     Attributes
     ----------
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -2548,7 +2548,7 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
     Parameters
     ----------
     grouped : Grouped DataFrame
-    subplots :
+    subplots : bool
         * ``False`` - no subplots will be used
         * ``True`` - create a subplot for each group
     column : column name or list of names, or vector


Test patch:
Repository: pandas-dev/pandas

Issue:
Spurious MultiIndex creation in `NDFrame._set_axis_names`
#### Code Sample, a copy-pastable example if possible

```python
# Code in master
pd.MultiIndex.from_product([["mammal"], ['dog', 'cat', 'monkey']])
```
#### Problem description

A spurious MultiIndex is being created in `_set_axis_names`.

[Link to blame](https://github.com/pandas-dev/pandas/blame/master/pandas/core/generic.py#L1336)


#### Expected Output

N/A

#### Output of ``pd.show_versions()``

N/A

<details>

[paste the output of ``pd.show_versions()`` here below this line]

</details>



Discussion:

Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -1333,7 +1333,6 @@ def _set_axis_name(self, name, axis=0, inplace=False):
                cat        4
                monkey     2
         """
-        pd.MultiIndex.from_product([["mammal"], ['dog', 'cat', 'monkey']])
         axis = self._get_axis_number(axis)
         idx = self._get_axis(axis).set_names(name)
 


Test patch:
Repository: pandas-dev/pandas

Issue:
pytest 3.10 minversion
Bug in parsing minversion: https://github.com/pytest-dev/pytest/issues/4306

this issue is to restore it.


Discussion:
Closed via #23520 
We'll keep this open for when pytest 3.10.1 is out, and we can add the min_version back to the setup.cfg.
> We'll keep this open for when pytest 3.10.1 is out, and we can add the min_version back to the setup.cfg.

@TomAugspurger : should we add this back in now? and if so, what min version?
Probably something in the 4.x range?

On Thu, Feb 21, 2019 at 9:31 AM Simon Hawkins <notifications@github.com>
wrote:

> We'll keep this open for when pytest 3.10.1 is out, and we can add the
> min_version back to the setup.cfg.
>
> @TomAugspurger <https://github.com/TomAugspurger> : should we add this
> back in now? and if so, what min version?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/issues/23519#issuecomment-466043515>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIgQLs08xzjOBqy3KjqLFIGAI4qeWks5vPrvVgaJpZM4YPJgN>
> .
>

i'll go with 4.0.2 and see if the ci checks pass.

Resolving patch:
diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py
--- a/pandas/util/_tester.py
+++ b/pandas/util/_tester.py
@@ -11,7 +11,7 @@ def test(extra_args=None):
     try:
         import pytest
     except ImportError:
-        raise ImportError("Need pytest>=3.0 to run tests")
+        raise ImportError("Need pytest>=4.0.2 to run tests")
     try:
         import hypothesis  # noqa
     except ImportError:


Test patch:
Repository: pandas-dev/pandas

Issue:
DOC: Fix and extend ParserError docstring
[`ParserError` says](https://github.com/pandas-dev/pandas/blob/8e51fd38607e94524b66ba15002e2502240baa32/pandas/errors/__init__.py#L35):
>Exception that is raised by an error encountered in `pd.read_csv`

however, it seems to be raised at least by html parsing, and perhaps other parsers as well: https://github.com/pandas-dev/pandas/blob/486e626bd3e7282b3da9993807f6246ef3ddda76/pandas/tests/io/test_html.py#L820-L829

As higher level point, it would be great if the list of potential runtime exceptions raised by the the various parsers were documented in the docs.


Discussion:
Thanks for this - PRs to update documentation are certainly welcome!
Hey, can I contribute to help fix this issue if no one else has yet?
@RjLi13  Look like nobody is working on it. Go for it.

Resolving patch:
diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py
--- a/pandas/errors/__init__.py
+++ b/pandas/errors/__init__.py
@@ -32,6 +32,8 @@ class UnsortedIndexError(KeyError):
 class ParserError(ValueError):
     """
     Exception that is raised by an error encountered in `pd.read_csv`.
+
+    e.g. HTML Parsing will raise this error.
     """
 
 


Test patch:
Repository: pandas-dev/pandas

Issue:
Plotting: secondary y axis can not be set to log scale
#### Code Sample, a copy-pastable example if possible

```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

pd.Series(np.random.random(1000)).plot(logy=True)
pd.Series(np.random.random(1000)).plot(secondary_y=True, logy=True)
plt.show()
```

#### Problem description

When I plot some data and set both the `secondary_y` and `logy` parameters to `True`, the `logy` parameter is not respected. Instead, the secondary y axis still uses linear scaling.

![logtest](https://user-images.githubusercontent.com/5310424/53807388-bb5e5a80-3f4f-11e9-8ae5-a897961ef821.png)

#### Expected Output

The secondary y axis should use logarithmic scaling.

![logtest](https://user-images.githubusercontent.com/5310424/53807551-29a31d00-3f50-11e9-8db0-8300dcb61013.png)

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.7.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.19.0-2-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: de_DE.UTF-8
LOCALE: de_DE.UTF-8
pandas: 0.24.1
pytest: 4.1.1
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.16.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: 1.8.3
patsy: None
dateutil: 2.7.3
pytz: 2018.9
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: 4.3.1
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

</details>



Discussion:
Thanks for the report. Interested in working on a fix?
Yep, I'll have a look in the next few days :) 

Resolving patch:
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -287,6 +287,9 @@ def _maybe_right_yaxis(self, ax, axes_num):
 
             if not self._has_plotted_object(orig_ax):  # no data on left y
                 orig_ax.get_yaxis().set_visible(False)
+
+            if self.logy or self.loglog:
+                new_ax.set_yscale('log')
             return new_ax
 
     def _setup_subplots(self):


Test patch:
diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py
--- a/pandas/tests/plotting/test_series.py
+++ b/pandas/tests/plotting/test_series.py
@@ -570,6 +570,18 @@ def test_df_series_secondary_legend(self):
         assert ax.get_yaxis().get_visible()
         tm.close()
 
+    @pytest.mark.slow
+    def test_secondary_logy(self):
+        # GH 25545
+        s1 = Series(np.random.randn(30))
+        s2 = Series(np.random.randn(30))
+
+        ax1 = s1.plot(logy=True)
+        ax2 = s2.plot(secondary_y=True, logy=True)
+
+        assert ax1.get_yscale() == 'log'
+        assert ax2.get_yscale() == 'log'
+
     @pytest.mark.slow
     def test_plot_fails_with_dupe_color_and_style(self):
         x = Series(randn(2))
Repository: pandas-dev/pandas

Issue:
BUG: User-facing AssertionError with DataFrame.to_html(classes=<invalid type>)
#### Code Sample, a copy-pastable example if possible

```python
import pandas as pd
pd.DataFrame().to_html(classes=True)
```
#### Problem description

```python-traceback
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\frame.py", line 2212, in to_html
    formatter.to_html(classes=classes, notebook=notebook, border=border)
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\format.py", line 729, in to_html
    html = Klass(self, classes=classes, border=border).render()
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\html.py", line 146, in render
    self._write_table()
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\io\formats\html.py", line 167, in _write_table
    .format(typ=type(self.classes)))
AssertionError: classes must be list or tuple, not <class 'bool'>
```

#### Expected Output

```python-traceback
TypeError: classes must be a string, list or tuple, not <class 'bool'>
```
#### Output of ``pd.show_versions()``

<details>

[paste the output of ``pd.show_versions()`` here below this line]

</details>



Discussion:
@mroeschke : the solution requires a change to one line of code, add a simple parametrised test and a whatsnew entry under bugfix. Can this be labelled good first issue?
Thanks for the suggestion! 
I can work on this

Resolving patch:
diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py
--- a/pandas/io/formats/html.py
+++ b/pandas/io/formats/html.py
@@ -163,8 +163,8 @@ def _write_table(self, indent=0):
             if isinstance(self.classes, str):
                 self.classes = self.classes.split()
             if not isinstance(self.classes, (list, tuple)):
-                raise AssertionError('classes must be list or tuple, not {typ}'
-                                     .format(typ=type(self.classes)))
+                raise TypeError('classes must be a string, list, or tuple, '
+                                'not {typ}'.format(typ=type(self.classes)))
             _classes.extend(self.classes)
 
         if self.table_id is None:


Test patch:
diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py
--- a/pandas/tests/io/formats/test_to_html.py
+++ b/pandas/tests/io/formats/test_to_html.py
@@ -623,3 +623,13 @@ def test_ignore_display_max_colwidth(method, expected, max_colwidth):
         result = getattr(df, method)()
     expected = expected(max_colwidth)
     assert expected in result
+
+
+@pytest.mark.parametrize("classes", [True, 0])
+def test_to_html_invalid_classes_type(classes):
+    # GH 25608
+    df = DataFrame()
+    msg = "classes must be a string, list, or tuple"
+
+    with pytest.raises(TypeError, match=msg):
+        df.to_html(classes=classes)
Repository: pandas-dev/pandas

Issue:
Using OrderedDict in GroupBy Module(s)
Spurred by conversation in https://github.com/pandas-dev/pandas/pull/25224#discussion_r264786749 right now we are using plain old dictionaries in most of the groupby aggregation functions. For Py35 this makes the order of the returned result non-deterministic.

We could theoretically make a stronger assertion around the order here by replacing those dicts with OrderedDicts


Discussion:
Since I've already been working with this, I will also continue with this issue. I'll make a simple WIP PR right now and will continue working on it. I'm thinking of changing the simple dicts to OrderedDicts in the aggregation functions of groupby and writing some tests in order to test the ordering.

Resolving patch:
diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py
--- a/pandas/core/groupby/generic.py
+++ b/pandas/core/groupby/generic.py
@@ -219,7 +219,7 @@ def _aggregate_generic(self, func, *args, **kwargs):
         axis = self.axis
         obj = self._obj_with_exclusions
 
-        result = {}
+        result = collections.OrderedDict()
         if axis != obj._info_axis_number:
             try:
                 for name, data in self:
@@ -246,7 +246,7 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
         # only for axis==0
 
         obj = self._obj_with_exclusions
-        result = {}
+        result = collections.OrderedDict()
         cannot_agg = []
         errors = None
         for item in obj:
@@ -899,7 +899,7 @@ def _get_index():
                           name=self._selection_name)
 
     def _aggregate_named(self, func, *args, **kwargs):
-        result = {}
+        result = collections.OrderedDict()
 
         for name, group in self:
             group.name = name


Test patch:
diff --git a/pandas/tests/groupby/aggregate/test_aggregate.py b/pandas/tests/groupby/aggregate/test_aggregate.py
--- a/pandas/tests/groupby/aggregate/test_aggregate.py
+++ b/pandas/tests/groupby/aggregate/test_aggregate.py
@@ -303,3 +303,15 @@ def test_groupby_agg_coercing_bools():
     result = gp['c'].aggregate(lambda x: x.isnull().all())
     expected = Series([True, False], index=index, name='c')
     tm.assert_series_equal(result, expected)
+
+
+def test_order_aggregate_multiple_funcs():
+    # GH 25692
+    df = pd.DataFrame({'A': [1, 1, 2, 2], 'B': [1, 2, 3, 4]})
+
+    res = df.groupby('A').agg(['sum', 'max', 'mean', 'ohlc', 'min'])
+    result = res.columns.levels[1]
+
+    expected = pd.Index(['sum', 'max', 'mean', 'ohlc', 'min'])
+
+    tm.assert_index_equal(result, expected)
Repository: pandas-dev/pandas

Issue:
BUG: DataFrame.update() drops timezone info
#### Code Sample

```python
import pandas as pd
import datetime as dt
import pytz as tz
data = pd.DataFrame([{'localized_date': dt.datetime(2018, 1, 12, 8, 15, tzinfo=tz.timezone('Europe/Berlin'))}])
data
"""
             localized_date
0 2018-01-12 08:22:00+01:00
"""
data.dtypes
"""
localized_date    datetime64[ns, Europe/Berlin]
dtype: object
"""
data.update(data)
data
"""
       localized_date
0 2018-01-12 07:22:00
"""
data.dtypes
"""
localized_date    datetime64[ns]
dtype: object
"""

```
#### Problem description
Update() method drops timezone info for datetime columns and cast all values to utc without a warning.

#### Output of ``pd.show_versions()``

<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-46-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.2
pytest: None
pip: 9.0.1
setuptools: 39.0.1
Cython: None
numpy: 1.16.2
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

</details>



Discussion:
pls search for a duplicate issue

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -5546,8 +5546,8 @@ def update(self, other, join='left', overwrite=True, filter_func=None,
         other = other.reindex_like(self)
 
         for col in self.columns:
-            this = self[col].values
-            that = other[col].values
+            this = self[col]._values
+            that = other[col]._values
             if filter_func is not None:
                 with np.errstate(all='ignore'):
                     mask = ~filter_func(this) | isna(that)


Test patch:
diff --git a/pandas/tests/frame/test_combine_concat.py b/pandas/tests/frame/test_combine_concat.py
--- a/pandas/tests/frame/test_combine_concat.py
+++ b/pandas/tests/frame/test_combine_concat.py
@@ -357,6 +357,13 @@ def test_update_from_non_df(self):
 
         assert_frame_equal(df, expected)
 
+    def test_update_datetime_tz(self):
+        # GH 25807
+        result = DataFrame([pd.Timestamp('2019', tz='UTC')])
+        result.update(result)
+        expected = DataFrame([pd.Timestamp('2019', tz='UTC')])
+        assert_frame_equal(result, expected)
+
     def test_join_str_datetime(self):
         str_dates = ['20120209', '20120222']
         dt_dates = [datetime(2012, 2, 9), datetime(2012, 2, 22)]
Repository: pandas-dev/pandas

Issue:
DateTimeIndex.to_frame() drops timezone in pandas 0.24
Behavior in pandas 0.23:
```python
>>> import pandas as pd
>>> pd.__version__
0.23.0
>>> x = pd.date_range(start='2019-01-01', end='2019-01-30', freq='D')
>>> x = x.tz_localize('UTC')
>>> x.to_frame().dtypes
0    datetime64[ns, UTC]
dtype: object
```

Behavior in pandas 0.24

```python
>>> import pandas as pd
>>> pd.__version__
0.24.2
>>> x = pd.date_range(start='2019-01-01', end='2019-01-30', freq='D')
>>> x = x.tz_localize('UTC')
>>> x.to_frame().dtypes
0    datetime64[ns]
dtype: object
```


Discussion:

Resolving patch:
diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py
--- a/pandas/core/indexes/base.py
+++ b/pandas/core/indexes/base.py
@@ -1208,7 +1208,7 @@ def to_frame(self, index=True, name=None):
         from pandas import DataFrame
         if name is None:
             name = self.name or 0
-        result = DataFrame({name: self.values.copy()})
+        result = DataFrame({name: self._values.copy()})
 
         if index:
             result.index = self


Test patch:
diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py
--- a/pandas/tests/indexes/common.py
+++ b/pandas/tests/indexes/common.py
@@ -85,6 +85,14 @@ def test_to_frame(self, name):
         df = idx.to_frame(index=False, name=idx_name)
         assert df.index is not idx
 
+    def test_to_frame_datetime_tz(self):
+        # GH 25809
+        idx = pd.date_range(start='2019-01-01', end='2019-01-30', freq='D')
+        idx = idx.tz_localize('UTC')
+        result = idx.to_frame()
+        expected = pd.DataFrame(idx, index=idx)
+        tm.assert_frame_equal(result, expected)
+
     def test_shift(self):
 
         # GH8083 test the base class for shift