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

Issue:
MultiIndex methods not listed in API reference
It would be really useful to have the documentation for the methods specific to `MultiIndex` such as `.from_product()` and `.from_tuples()` to be listed with links in the API reference (http://pandas.pydata.org/pandas-docs/stable/api.html). 

I'm willing to edit the api.rst file, but when I build the docs from scratch (using `python make.py html`), the resulting api.html file is incomplete.  Before I make changes, I'd like to make sure the build of the docs works right.  Maybe the build issue should be a different issue?



Discussion:
I think it would certainly be good to add these to the api.rst page.

About the doc building, what do you exactly mean with 'incomplete'? If you don't have a specific issue that can be reported, but like more general help, it can also be easier to use the gitter channel to help you instead of github issues -> https://gitter.im/pydata/pandas

For later reference, the doc building issue was that I was using Sphinx 1.3.1.  Using Sphinx 1.3.3 fixed the problem.  Now I will update the api.rst page.


Resolving patch:
diff --git a/pandas/core/index.py b/pandas/core/index.py
--- a/pandas/core/index.py
+++ b/pandas/core/index.py
@@ -4022,8 +4022,7 @@ def isin(self, values, level=None):
 class MultiIndex(Index):
 
     """
-    Implements multi-level, a.k.a. hierarchical, index object for pandas
-    objects
+    A multi-level, or hierarchical, index object for pandas objects
 
     Parameters
     ----------


Test patch:
Repository: pandas-dev/pandas

Issue:
BUG: masking empty DataFrame
 Issue #10126 seems not fixed completely. I still get the same error when running the same example. I have looked up the code and found that _getitem_frame was not fixed yet.  The fix is easy, just the same as _setitem_frame.



Discussion:

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -2047,7 +2047,7 @@ def _getitem_multilevel(self, key):
             return self._get_item_cache(key)
 
     def _getitem_frame(self, key):
-        if key.values.dtype != np.bool_:
+        if key.values.size and not com.is_bool_dtype(key.values):
             raise ValueError('Must pass DataFrame with boolean values only')
         return self.where(key)
 


Test patch:
diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py
--- a/pandas/tests/test_frame.py
+++ b/pandas/tests/test_frame.py
@@ -826,6 +826,13 @@ def test_setitem_empty_frame_with_boolean(self):
                 df[df > df2] = 47
                 assert_frame_equal(df, df2)
 
+    def test_getitem_empty_frame_with_boolean(self):
+        # Test for issue #11859
+
+        df = pd.DataFrame()
+        df2 = df[df>0]
+        assert_frame_equal(df, df2)
+
     def test_delitem_corner(self):
         f = self.frame.copy()
         del f['D']
Repository: pandas-dev/pandas

Issue:
Error in doc of DatetimeIndex.indexer_between_time
Hello everyone, 

This is not a major issue: I was trying to use the `tz` parameter as indicated on the [documentation](http://pandas.pydata.org/pandas-docs/version/0.17.1/generated/pandas.DatetimeIndex.indexer_between_time.html?highlight=indexer_between_time#pandas.DatetimeIndex.indexer_between_time) of `DatetimeIndex.indexer_between_time` and it turns out that `tz` is not implemented.

Here is an example:

``` python
import pandas as pd
pd.DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00', '2016-01-01 02:00:00']).indexer_between_time('01:00', '02:00', tz='Europe/Paris')
```

```
Traceback (most recent call last):
  File "~/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-98-258497b42264>", line 1, in <module>
    pd.DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00', '2016-01-01 02:00:00']).indexer_between_time('01:00', '02:00', tz='Europe/Paris')
TypeError: indexer_between_time() got an unexpected keyword argument 'tz'
```



Discussion:
That doc should be fixed (and you see the signature no longer has a tz argument).  Having a `tz` makes no sense in this context.

@joseRLC want to do a pull-request for that?

Can I try this out? This seems like a good issue for a first PR.

@RahulHP Certainly, go for it! If you have any questions about the workflow (see http://pandas.pydata.org/pandas-docs/stable/contributing.html), just ask (you can also use the gitter channel for that: https://gitter.im/pydata/pandas)


Resolving patch:
diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py
--- a/pandas/tseries/index.py
+++ b/pandas/tseries/index.py
@@ -1804,7 +1804,6 @@ def indexer_between_time(self, start_time, end_time, include_start=True,
             "%I%M%S%p")
         include_start : boolean, default True
         include_end : boolean, default True
-        tz : string or pytz.timezone or dateutil.tz.tzfile, default None
 
         Returns
         -------


Test patch:
Repository: pandas-dev/pandas

Issue:
Accessor api docs not building with sphinx 1.3.x
Our custom `AccessorDocumenter`s (defined in docs/source.conf.py) are not working anymore with sphinx 1.3.x

See eg the doc build on travis for the errors, and the api overview page on the dev docs.



Discussion:

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -318,6 +318,7 @@
 # Add custom Documenter to handle attributes/methods of an AccessorProperty
 # eg pandas.Series.str and pandas.Series.dt (see GH9322)
 
+import sphinx
 from sphinx.util import rpartition
 from sphinx.ext.autodoc import Documenter, MethodDocumenter, AttributeDocumenter
 from sphinx.ext.autosummary import Autosummary
@@ -365,7 +366,10 @@ def resolve_name(self, modname, parents, path, base):
             if not modname:
                 modname = self.env.temp_data.get('autodoc:module')
             if not modname:
-                modname = self.env.temp_data.get('py:module')
+                if sphinx.__version__ > '1.3':
+                    modname = self.env.ref_context.get('py:module')
+                else:
+                    modname = self.env.temp_data.get('py:module')
             # ... else, it stays None, which means invalid
         return modname, parents + [base]
 


Test patch:
Repository: pandas-dev/pandas

Issue:
ENH: add errors='raise' option to rename
Is there a reason that `.rename` doesn't raise if keys are supplied that don't exist? This caught me out a couple of times:

``` python
In [14]: import pandas as pd

In [15]: df=pd.DataFrame({'a': [1,2], 'b': [3,4]})

In [16]: df
Out[16]: 
   a  b
0  1  3
1  2  4

In [17]: df.rename(columns={'a': 'c'})
Out[17]: 
   c  b
0  1  3
1  2  4
# ok

In [18]: df.rename(columns={'d': 'c'})
Out[18]: 
   a  b
0  1  3
1  2  4

# this should raise?
```



Discussion:
I suspect it is intentional. Either way, the behavior should be clarified in the docs. Missing keys (in columns but not in the dict) are explicitly documented.

I know I've used this in the past. For example a bunch of CSVs with variations on the same items. I'll make one dictionary with all the mappings

``` python
renamer = {'zip': 'zip_code', 'postal code': 'zip_code', ...}`
```

And use that same `renamer` on many dataframes.

OK. You know this better than me - do you think this is too much vs the increase in explicitness?

``` python
df.rename(columns={col: renamer[col] for col in renamer if col in df.columns})
```


Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -555,8 +555,8 @@ def swaplevel(self, i=-2, j=-1, axis=0):
     _shared_docs['rename'] = """
         Alter axes input function or functions. Function / dict values must be
         unique (1-to-1). Labels not contained in a dict / Series will be left
-        as-is. Alternatively, change ``Series.name`` with a scalar
-        value (Series only).
+        as-is. Extra labels listed don't throw an error. Alternatively, change
+        ``Series.name`` with a scalar value (Series only).
 
         Parameters
         ----------
@@ -611,6 +611,11 @@ def swaplevel(self, i=-2, j=-1, axis=0):
         0  1  4
         1  2  5
         2  3  6
+        >>> df.rename(index=str, columns={"A": "a", "C": "c"})
+           a  B
+        0  1  4
+        1  2  5
+        2  3  6
         """
 
     @Appender(_shared_docs['rename'] % dict(axes='axes keywords for this'


Test patch:
Repository: pandas-dev/pandas

Issue:
DOCS: Mistake in .cum* descriptions
For the .cum\* functions the generated documentation description is redundant. As an example, [DataFrame.cumsum()](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumsum.html?highlight=cumsum#pandas.DataFrame.cumsum) has the description "Return cumulative cumsum over requested axis." when it should say "Return cumulative sum over requested axis.". 

After looking into this, I found the problem on line 5507 of generic.py where the _name_ is being used instead of the _desc_. 

DOCS: Mistake in .cum* descriptions
For the .cum\* functions the generated documentation description is redundant. As an example, [DataFrame.cumsum()](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.cumsum.html?highlight=cumsum#pandas.DataFrame.cumsum) has the description "Return cumulative cumsum over requested axis." when it should say "Return cumulative sum over requested axis.". 

After looking into this, I found the problem on line 5507 of generic.py where the _name_ is being used instead of the _desc_. 



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
@@ -5504,7 +5504,7 @@ def _make_cum_function(cls, name, name1, name2, axis_descr, desc, accum_func,
                        mask_a, mask_b):
     @Substitution(outname=name, desc=desc, name1=name1, name2=name2,
                   axis_descr=axis_descr)
-    @Appender("Return cumulative {0} over requested axis.".format(name) +
+    @Appender("Return {0} over requested axis.".format(desc) +
               _cnum_doc)
     def cum_func(self, axis=None, skipna=True, *args, **kwargs):
         skipna = nv.validate_cum_func_with_skipna(skipna, args, kwargs, name)


Test patch:
Repository: pandas-dev/pandas

Issue:
Multicharacter delimiters + non-UTF8 encoding doesn't work correctly in parsers
The new C parser handles user-specified encoding properly. The Python parser not so much (I think it may only be an issue when regular-expression parsing is used). 



Discussion:
@jreback : is it me, or is this no longer an issue?  The `common.py` tests have several encoding ones.

But I don't see directly any test with the combination of an encoding and a multi-character `sep`? (so maybe we should add a test for that?)


Resolving patch:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -1871,6 +1871,10 @@ class MyDialect(csv.Dialect):
         else:
             def _read():
                 line = f.readline()
+
+                if compat.PY2 and self.encoding:
+                    line = line.decode(self.encoding)
+
                 pat = re.compile(sep)
                 yield pat.split(line.strip())
                 for line in f:


Test patch:
diff --git a/pandas/io/tests/parser/python_parser_only.py b/pandas/io/tests/parser/python_parser_only.py
--- a/pandas/io/tests/parser/python_parser_only.py
+++ b/pandas/io/tests/parser/python_parser_only.py
@@ -201,3 +201,19 @@ def test_skipfooter_with_decimal(self):
         result = self.read_csv(StringIO(data), names=['a'],
                                decimal='#', skipfooter=1)
         tm.assert_frame_equal(result, expected)
+
+    def test_encoding_non_utf8_multichar_sep(self):
+        # see gh-3404
+        expected = DataFrame({'a': [1], 'b': [2]})
+
+        for sep in ['::', '#####', '!!!', '123', '#1!c5',
+                    '%!c!d', '@@#4:2', '_!pd#_']:
+            data = '1' + sep + '2'
+
+            for encoding in ['utf-16', 'utf-16-be', 'utf-16-le',
+                             'utf-32', 'cp037']:
+                encoded_data = data.encode(encoding)
+                result = self.read_csv(BytesIO(encoded_data),
+                                       sep=sep, names=['a', 'b'],
+                                       encoding=encoding)
+                tm.assert_frame_equal(result, expected)
Repository: pandas-dev/pandas

Issue:
CLN: template hashtable.pyx
use Tempita support to provide templates for routines in `hashtable.pyx`. Lots of duplicated code by dtype that can easily use fused types, so code generation is needed. Following along the lines of #13716 would be nice.



Discussion:
I'm going to handle. What do you think adding other dtypes like `int32`, etc (related to #701?).  


Resolving patch:
diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py
--- a/pandas/core/algorithms.py
+++ b/pandas/core/algorithms.py
@@ -413,7 +413,7 @@ def _value_counts_arraylike(values, dropna=True):
             freq = values.freq
 
         values = values.view(np.int64)
-        keys, counts = htable.value_count_scalar64(values, dropna)
+        keys, counts = htable.value_count_int64(values, dropna)
 
         if dropna:
             msk = keys != iNaT
@@ -434,10 +434,10 @@ def _value_counts_arraylike(values, dropna=True):
 
     elif is_integer_dtype(dtype):
         values = _ensure_int64(values)
-        keys, counts = htable.value_count_scalar64(values, dropna)
+        keys, counts = htable.value_count_int64(values, dropna)
     elif is_float_dtype(dtype):
         values = _ensure_float64(values)
-        keys, counts = htable.value_count_scalar64(values, dropna)
+        keys, counts = htable.value_count_float64(values, dropna)
     else:
         values = _ensure_object(values)
         mask = isnull(values)
diff --git a/pandas/core/groupby.py b/pandas/core/groupby.py
--- a/pandas/core/groupby.py
+++ b/pandas/core/groupby.py
@@ -4399,7 +4399,7 @@ def _groupby_indices(values):
         # bit better than factorizing again
         reverse = dict(enumerate(values.categories))
         codes = values.codes.astype('int64')
-        _, counts = _hash.value_count_scalar64(codes, False)
+        _, counts = _hash.value_count_int64(codes, False)
     else:
         reverse, codes, counts = _algos.group_labels(
             _values_from_object(_ensure_object(values)))
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -107,7 +107,8 @@ def is_platform_mac():
 
 _pxipath = pjoin('pandas', 'src')
 _pxifiles = ['algos_common_helper.pxi.in', 'algos_groupby_helper.pxi.in',
-             'algos_join_helper.pxi.in', 'algos_take_helper.pxi.in']
+             'algos_join_helper.pxi.in', 'algos_take_helper.pxi.in',
+             'hashtable_class_helper.pxi.in', 'hashtable_func_helper.pxi.in']
 
 
 class build_ext(_build_ext):


Test patch:
Repository: pandas-dev/pandas

Issue:
Assigning a string index as a column once can make further assignments affect both index and column.
If you assign the dataframe's index to as a column as well, without resetting the index, any subsequent assignments on the column seem to affect both the column as well as the index.
The behaviour is there for Index, Int64Index, and Float64Index but not DatetimeIndex.
#### Code Sample, a copy-pastable example if possible.

``` python
>>> import pandas as pd
>>> df=pd.DataFrame(index=['A', 'B', 'C'])
>>> df['X']=df.index
>>> df
   X
A  A
B  B
C  C
>>> df['X']=['x', 'y', 'z']
>>> df
   X
x  x
y  y
z  z
>>> df.ix[0, 'X']='q'
>>> df
   X
q  q
y  y
z  z
```
#### Expected Output

``` python
   X
A  x
B  y
C  z
```
#### output of `pd.show_versions()`

``` python
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 23.0.0
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.1
statsmodels: None
xarray: 0.7.2
IPython: None
sphinx: None
patsy: None
dateutil: 2.4.1
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
```



Discussion:
hmm these are supposed to be copied when coming from s column
not sure what happened


Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -2638,6 +2638,8 @@ def reindexer(value):
                     value = com._asarray_tuplesafe(value)
             elif value.ndim == 2:
                 value = value.copy().T
+            elif isinstance(value, Index):
+                value = value.copy(deep=True)
             else:
                 value = value.copy()
 


Test patch:
diff --git a/pandas/tests/frame/test_mutate_columns.py b/pandas/tests/frame/test_mutate_columns.py
--- a/pandas/tests/frame/test_mutate_columns.py
+++ b/pandas/tests/frame/test_mutate_columns.py
@@ -156,6 +156,13 @@ def test_insert(self):
         df.insert(0, 'baz', df['c'])
         self.assertEqual(df.columns.name, 'some_name')
 
+        # GH 13522
+        df = DataFrame(index=['A', 'B', 'C'])
+        df['X'] = df.index
+        df['X'] = ['x', 'y', 'z']
+        exp = DataFrame(data={'X': ['x', 'y', 'z']}, index=['A', 'B', 'C'])
+        assert_frame_equal(df, exp)
+
     def test_delitem(self):
         del self.frame['A']
         self.assertNotIn('A', self.frame)
Repository: pandas-dev/pandas

Issue:
keep consistency in calling to_csv either dataframe or series
When I call to_csv of dataframe object, I am not required to explicitly set path parameter. The default one is None and will return a string. I thought the same thing for series object. This time the path parameter becomes explicitly required. I wonder if it is better to keep consistency between them.



Discussion:
Can u show an explicit example and pd.show_versions()

@jreback : There is no need.  @FrankMN is referring to a signature mismatch, which you can see <a href="https://github.com/pydata/pandas/blob/51b20de44fdcb998f25392558e029621e10c451c/pandas/core/series.py#L2536">here</a> and <a href=https://github.com/pydata/pandas/blob/51b20de44fdcb998f25392558e029621e10c451c/pandas/core/frame.py#L1302>here</a>.  IMO we should default `path=None` for `Series`.  This shouldn't be a breaking API change.


Resolving patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -2538,16 +2538,17 @@ def from_csv(cls, path, sep=',', parse_dates=True, header=None,
 
         return result
 
-    def to_csv(self, path, index=True, sep=",", na_rep='', float_format=None,
-               header=False, index_label=None, mode='w', encoding=None,
-               date_format=None, decimal='.'):
+    def to_csv(self, path=None, index=True, sep=",", na_rep='',
+               float_format=None, header=False, index_label=None,
+               mode='w', encoding=None, date_format=None, decimal='.'):
         """
         Write Series to a comma-separated values (csv) file
 
         Parameters
         ----------
-        path : string file path or file handle / StringIO. If None is provided
-            the result is returned as a string.
+        path : string or file handle, default None
+            File path or object, if None is provided the result is returned as
+            a string.
         na_rep : string, default ''
             Missing data representation
         float_format : string, default None


Test patch:
Repository: pandas-dev/pandas

Issue:
DOC: read_excel() documentation for na_values should show default na values
I'd like to see read_excel show the same valid information for na_values as read_csv does. This ended up taking a lot of digging to find because it was unclear what the defaults were with read_excel().
#### read_csv() documentation shows the following for na_values

na_values : str or list-like or dict, default None
Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values. By default the following values are interpreted as NaN: ‘’, ‘#N/A’, ‘#N/A N/A’, ‘#NA’, ‘-1.#IND’, ‘-1.#QNAN’, ‘-NaN’, ‘-nan’, ‘1.#IND’, ‘1.#QNAN’, ‘N/A’, ‘NA’, ‘NULL’, ‘NaN’, ‘nan’.
#### read_excel() documentation does not include default NaN values

na_values : list-like, default None
List of additional strings to recognize as NA/NaN



Discussion:
Thx for the suggestion. PR is appreciated!

I wish to work on the issue. How do I start?

First, look at the contributing docs (http://pandas.pydata.org/pandas-docs/stable/contributing.html) which explains how to set-up a development environment and to make a pull request. 

Specifically for this change, you can take a look at the `read_csv` docstring, which includes the correct values for `na_values`. So you could just copy the explanation from there.


Resolving patch:
diff --git a/pandas/io/excel.py b/pandas/io/excel.py
--- a/pandas/io/excel.py
+++ b/pandas/io/excel.py
@@ -29,6 +29,7 @@
 from warnings import warn
 from distutils.version import LooseVersion
 from pandas.util.decorators import Appender
+from textwrap import fill
 
 __all__ = ["read_excel", "ExcelWriter", "ExcelFile"]
 
@@ -97,7 +98,7 @@
 na_values : scalar, str, list-like, or dict, default None
     Additional strings to recognize as NA/NaN. If dict passed, specific
     per-column NA values. By default the following values are interpreted
-    as NaN: '""" + "', '".join(sorted(_NA_VALUES)) + """'.
+    as NaN: '""" + fill("', '".join(sorted(_NA_VALUES)), 70) + """'.
 thousands : str, default None
     Thousands separator for parsing string columns to numeric.  Note that
     this parameter is only necessary for columns stored as TEXT in Excel,
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -7,6 +7,7 @@
 import csv
 import warnings
 import datetime
+from textwrap import fill
 
 import numpy as np
 
@@ -132,7 +133,7 @@
 na_values : scalar, str, list-like, or dict, default None
     Additional strings to recognize as NA/NaN. If dict passed, specific
     per-column NA values.  By default the following values are interpreted as
-    NaN: `'""" + "'`, `'".join(sorted(_NA_VALUES)) + """'`.
+    NaN: '""" + fill("', '".join(sorted(_NA_VALUES)), 70) + """'`.
 keep_default_na : bool, default True
     If na_values are specified and keep_default_na is False the default NaN
     values are overridden, otherwise they're appended to.


Test patch: