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

Issue:
DOC: docs don't build with new Sphinx version 1.2
I always build the docs with Sphinx 1.1.3, but recently (in december) a new Sphinx version was released: 1.2. 

And it seems that the docs won't build with this new version (also mentioned in #5530 and https://github.com/pydata/pandas/pull/5701#discussion_r8715560). You get the following error:

```
  File "C:\Users\vdbosscj\Scipy\pandas-joris\doc\source\_templates\autosummary/class.rst", line 1, in top-level template code
    {% extends "!autosummary/class.rst" %}
  File "C:\Anaconda\envs\devel2\lib\site-packages\jinja2\utils.py", line 339, in get
    return self[key]
  File "C:\Anaconda\envs\devel2\lib\site-packages\jinja2\utils.py", line 389, in __getitem__
    if self._queue[-1] != key:
RuntimeError: maximum recursion depth exceeded in cmp
```

This has something to do with the class.rst template for autosummary (which we extend in [doc/source/_templates/autosummary/class.rst](https://github.com/pydata/pandas/blob/master/doc/source/_templates/autosummary/class.rst))

If you remove the template class.rst, the docs will build (you only will get a bunch of warnings because of links to non-existing documents, because not all docstring pages are built (that was the reason for the template)).



Discussion:
@pv Do you know if you also have this issue with numpy? (Because I copied the approach of the class.rst template from the numpy docs)


Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -12,6 +12,7 @@
 
 import sys
 import os
+from pandas.compat import u
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -63,8 +64,8 @@
 master_doc = 'index'
 
 # General information about the project.
-project = u'pandas'
-copyright = u'2008-2012, the pandas development team'
+project = u('pandas')
+copyright = u('2008-2014, the pandas development team')
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -211,8 +212,8 @@
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
     ('index', 'pandas.tex',
-     u'pandas: powerful Python data analysis toolkit',
-     u'Wes McKinney\n\& PyData Development Team', 'manual'),
+     u('pandas: powerful Python data analysis toolkit'),
+     u('Wes McKinney\n\& PyData Development Team'), 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of


Test patch:
Repository: pandas-dev/pandas

Issue:
BUG: Copying an empty DataFrame with index results in a broken BlockManager
The following line illustrates the problem:

```
df = pd.DataFrame(index=[0]).copy()
df["a"] = 0
```

This results in an `AttributeError` since the function `BlockManager.make_empty` initialises `df._data.blocks` with a numpy array object instead of an empty list. Thus subsequent calls to `blocks.pop` and `blocks.append` fail.

I have a patch coming up.



Discussion:
Maybe not, the patch is at https://github.com/filmor/pandas/commit/2c9f7d3981dd1f66267b43910c7803af99083b27, but a test fails (https://travis-ci.org/filmor/pandas/jobs/16920606). What is the rationale behind having a `dtype` for the `BlockManager`?


Resolving patch:
diff --git a/pandas/core/internals.py b/pandas/core/internals.py
--- a/pandas/core/internals.py
+++ b/pandas/core/internals.py
@@ -1961,8 +1961,11 @@ def make_empty(self, axes=None):
             ]
 
         # preserve dtype if possible
-        dtype = self.dtype if self.ndim == 1 else object
-        return self.__class__(np.array([], dtype=dtype), axes)
+        if self.ndim == 1:
+            blocks = np.array([], dtype=self.dtype)
+        else:
+            blocks = []
+        return self.__class__(blocks, axes)
 
     def __nonzero__(self):
         return True


Test patch:
diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py
--- a/pandas/tests/test_indexing.py
+++ b/pandas/tests/test_indexing.py
@@ -1843,6 +1843,14 @@ def f():
         df = DataFrame(Series(name='foo'))
         assert_frame_equal(df, DataFrame({ 'foo' : Series() }))
 
+        # GH 5932
+        # copy on empty with assignment fails
+        df = DataFrame(index=[0])
+        df = df.copy()
+        df['a'] = 0
+        expected = DataFrame(0,index=[0],columns=['a'])
+        assert_frame_equal(df, expected)
+
     def test_cache_updating(self):
         # GH 4939, make sure to update the cache on setitem
Repository: pandas-dev/pandas

Issue:
API: add read_gbq to pandas.io.api so it appears in top-level name space



Discussion:
Note for when this is done: the entry in api.rst should also be updated then.

If it's experimental, should it actually go there? 

yes it makes sense to do this 

Okay


Resolving patch:
diff --git a/pandas/io/api.py b/pandas/io/api.py
--- a/pandas/io/api.py
+++ b/pandas/io/api.py
@@ -12,3 +12,4 @@
 from pandas.io.stata import read_stata
 from pandas.io.pickle import read_pickle, to_pickle
 from pandas.io.packers import read_msgpack, to_msgpack
+from pandas.io.gbq import read_gbq
diff --git a/pandas/io/gbq.py b/pandas/io/gbq.py
--- a/pandas/io/gbq.py
+++ b/pandas/io/gbq.py
@@ -13,8 +13,9 @@
 import pandas as pd
 import numpy as np
 
-from pandas import DataFrame, concat
 from pandas.core.common import PandasError
+from pandas.core.frame import DataFrame
+from pandas.tools.merge import concat
 
 try:
     import bq


Test patch:
Repository: pandas-dev/pandas

Issue:
BUG: Scipy interpolate methods are not datetime64 aware
From [this SO question](http://stackoverflow.com/questions/21169182/interpolation-for-some-methods-is-failing-with-a-type-error).

Is this something we should worry about here, or report upstream to scipy? The workaround I posted on SO is just to explicitly recast the index as an int64, interpolate on that, and then reset the original index. Any reason we shouldn't do this internally?



Discussion:
@TomAugspurger I think you may need to do a ``values.view('i8')` before passing if they are dtype.kind of 'M' or 'm'


Resolving patch:
diff --git a/pandas/core/common.py b/pandas/core/common.py
--- a/pandas/core/common.py
+++ b/pandas/core/common.py
@@ -1401,6 +1401,7 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
     """
     try:
         from scipy import interpolate
+        from pandas import DatetimeIndex
     except ImportError:
         raise ImportError('{0} interpolation requires Scipy'.format(method))
 
@@ -1413,6 +1414,10 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
         'piecewise_polynomial': interpolate.piecewise_polynomial_interpolate,
     }
 
+    if hasattr(x, 'asi8'):
+        # GH 5975, scipy.interp1d can't hande datetime64s
+        x, new_x = x.values.view('i8'), new_x.view('i8')
+
     try:
         alt_methods['pchip'] = interpolate.pchip_interpolate
     except AttributeError:


Test patch:
diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py
--- a/pandas/tests/test_generic.py
+++ b/pandas/tests/test_generic.py
@@ -587,6 +587,13 @@ def test_interp_nonmono_raise(self):
         with tm.assertRaises(ValueError):
             s.interpolate(method='krogh')
 
+    def test_interp_datetime64(self):
+        _skip_if_no_scipy()
+        df = Series([1, np.nan, 3], index=date_range('1/1/2000', periods=3))
+        result = df.interpolate(method='nearest')
+        expected = Series([1, 1, 3], index=date_range('1/1/2000', periods=3))
+        assert_series_equal(result, expected)
+
 class TestDataFrame(tm.TestCase, Generic):
     _typ = DataFrame
     _comparator = lambda self, x, y: assert_frame_equal(x,y)
Repository: pandas-dev/pandas

Issue:
BUG: Scipy interpolate methods are not datetime64 aware
From [this SO question](http://stackoverflow.com/questions/21169182/interpolation-for-some-methods-is-failing-with-a-type-error).

Is this something we should worry about here, or report upstream to scipy? The workaround I posted on SO is just to explicitly recast the index as an int64, interpolate on that, and then reset the original index. Any reason we shouldn't do this internally?



Discussion:
@TomAugspurger I think you may need to do a ``values.view('i8')` before passing if they are dtype.kind of 'M' or 'm'

reopening for https://github.com/pydata/pandas/pull/5977#issuecomment-32691271


Resolving patch:
diff --git a/pandas/core/common.py b/pandas/core/common.py
--- a/pandas/core/common.py
+++ b/pandas/core/common.py
@@ -1414,9 +1414,9 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
         'piecewise_polynomial': interpolate.piecewise_polynomial_interpolate,
     }
 
-    if hasattr(x, 'asi8'):
+    if getattr(x, 'is_all_dates', False):
         # GH 5975, scipy.interp1d can't hande datetime64s
-        x, new_x = x.values.view('i8'), new_x.view('i8')
+        x, new_x = x.values.astype('i8'), new_x.astype('i8')
 
     try:
         alt_methods['pchip'] = interpolate.pchip_interpolate


Test patch:
Repository: pandas-dev/pandas

Issue:
s390 test failure: file descriptor cannot be a negative integer
full log https://buildd.debian.org/status/fetch.php?pkg=pandas&arch=s390x&ver=0.13.0-2&stamp=1390095775&file=log

```
======================================================================
ERROR: test_flush (pandas.io.tests.test_pytables.TestHDFStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/«PKGBUILDDIR»/debian/tmp/usr/lib/python2.7/dist-packages/pandas/io/tests/test_pytables.py", line 523, in test_flush
    store.flush(fsync=True)
  File "/«PKGBUILDDIR»/debian/tmp/usr/lib/python2.7/dist-packages/pandas/io/pytables.py", line 571, in flush
    os.fsync(self._handle.fileno())
ValueError: file descriptor cannot be a negative integer (-1)
```

may be due to a recent update to pytables 3.0.0-2



Discussion:

Resolving patch:
diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py
--- a/pandas/io/pytables.py
+++ b/pandas/io/pytables.py
@@ -568,7 +568,10 @@ def flush(self, fsync=False):
         if self._handle is not None:
             self._handle.flush()
             if fsync:
-                os.fsync(self._handle.fileno())
+                try:
+                    os.fsync(self._handle.fileno())
+                except:
+                    pass
 
     def get(self, key):
         """


Test patch:
Repository: pandas-dev/pandas

Issue:
Could the html documentation be provided for download
I like html documentation for offline browsing. I wonder if pandas could do the same as django or the official python documentation to provide a html tarball for download. Thank you.

BTW, I have tried building the pandas html documentation from a git checkout and didn't succeed.



Discussion:
what errors do you get when you try to build the docs?
I'll add the tarball when I get a chance. please stay tuned.

I don't mean to be prying or anything, but are there any updates on this? An offline-browsable version of the docs would be very awesome indeed. :)


Resolving patch:
diff --git a/doc/make.py b/doc/make.py
--- a/doc/make.py
+++ b/doc/make.py
@@ -103,7 +103,14 @@ def html():
     if os.system('sphinx-build -P -b html -d build/doctrees '
                  'source build/html'):
         raise SystemExit("Building HTML failed.")
-
+    try:
+        print("\nZipping up HTML docs...")
+        # just in case the wonky build box doesn't have zip
+        # don't fail this.
+        os.system('cd build; rm -f html/pandas.zip; zip html/pandas.zip -r -q html/* ')
+        print("\n")
+    except:
+        pass
 
 def latex():
     check_build()


Test patch:
Repository: pandas-dev/pandas

Issue:
Negative NaN (-nan) in CSV input treated as object
The value "-nan" (yes, this is a valid type of NaN!) in a CSV input file causes that column to be treated as 'object' instead of float64.

```
pd.read_csv(StringIO.StringIO('a,b\n1,2.0\n2,nan\n3,-nan')).b
Out[15]: 
0     2.0
1     NaN
2    -nan
Name: b, dtype: object

pd.read_csv(StringIO.StringIO('a,b\n1,2.0\n2,nan\n')).b
Out[16]: 
0     2
1   NaN
Name: b, dtype: float64
```

When the file is sufficiently large, the following error is generated:

```
In [3]: pd.read_csv('big.bad.csv')
/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py:1033: DtypeWarning: Columns (58,64) have mixed types. Specify dtype option on import or set low_memory=False.
  data = self._reader.read(nrows)
```

If the string "-nan" is replaced with "nan" all is well.  I don't really need to distinguish negative NaN from NaN but would like to be able to read my data files w/o having to pre-process them to scrub all the '-nan's.



Discussion:
try specifying it as a na_value see here: http://pandas.pydata.org/pandas-docs/dev/io.html#na-values
lmk if this works; what version of pandas?

`pd.read_csv(StringIO.StringIO('a,b\n1,2.0\n2,nan\n3,-nan'), na-values=['-nan']).b`

works

I don't have a problem with making `-nan` a default nan value; if you would like to do a PR would be great


Resolving patch:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -449,7 +449,7 @@ def read_fwf(filepath_or_buffer, colspecs='infer', widths=None, **kwds):
 # '1.#INF','-1.#INF', '1.#INF000000',
 _NA_VALUES = set([
     '-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A', 'N/A', 'NA', '#NA',
-    'NULL', 'NaN', 'nan', ''
+    'NULL', 'NaN', '-NaN', 'nan', '-nan', ''
 ])
 
 


Test patch:
diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py
--- a/pandas/io/tests/test_parsers.py
+++ b/pandas/io/tests/test_parsers.py
@@ -33,6 +33,7 @@
 import pandas.tseries.tools as tools
 
 from numpy.testing.decorators import slow
+from numpy.testing import assert_array_equal
 
 from pandas.parser import OverflowError
 
@@ -685,8 +686,8 @@ def test_non_string_na_values(self):
     def test_default_na_values(self):
         _NA_VALUES = set(['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN',
                           '#N/A','N/A', 'NA', '#NA', 'NULL', 'NaN',
-                          'nan', ''])
-
+                          'nan', '-NaN', '-nan', ''])
+        assert_array_equal (_NA_VALUES, parsers._NA_VALUES)
         nv = len(_NA_VALUES)
         def f(i, v):
             if i == 0:
Repository: pandas-dev/pandas

Issue:
Latest ipython master complains of exceptions in df._repr_html_
https://github.com/ipython/ipython/issues/4792

`df.repr_html` currently raises `ValueError`. if IPython agree to the
proposed behaviour,  we'll change it to `NotImplementedError` to restore things to normal.



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
@@ -474,7 +474,8 @@ def _repr_html_(self):
         # behaves badly when outputting an HTML table
         # that doesn't fit the window, so disable it.
         if com.in_qtconsole():
-            raise NotImplementedError('HTML output is disabled in QtConsole')
+            # 'HTML output is disabled in QtConsole'
+            return None
 
         if self._info_repr():
             buf = StringIO(u(""))


Test patch:
Repository: pandas-dev/pandas

Issue:
pandas.Series.str raises wrong exception
Use the following code snippet to reproduce:

``` python
>>> import pandas
>>> pandas.Series.str
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "properties.pyx", line 25, in pandas.lib.cache_readonly.__get__ (pandas/lib.c:29334)
AttributeError: 'NoneType' object has no attribute '_cache'
```

Expected: a more clear message like:

``` python
>>> pandas.Series.bjdksalfjak
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Series' has no attribute 'bjdksalfjak'
```

The current behaviour sends the wrong message, as I've discovered with some difficulty trying to debug https://github.com/pydata/pandas/pull/5530#issuecomment-33304367



Discussion:
easy fix

str is an 'internal' name

just a needs adding to NDFrame._internal_names

this makes it take a different different path
raise an attribute error which is then caught and creates the string method class

I should make this more like how the indexers work so it bypasses all of this


Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -79,7 +79,7 @@ class NDFrame(PandasObject):
     copy : boolean, default False
     """
     _internal_names = ['_data', '_cacher', '_item_cache', '_cache',
-                       'is_copy', '_subtyp', '_index', '_default_kind',
+                       'is_copy', 'str', '_subtyp', '_index', '_default_kind',
                        '_default_fill_value','__array_struct__','__array_interface__']
     _internal_names_set = set(_internal_names)
     _metadata = []
@@ -616,7 +616,7 @@ def equals(self, other):
         if not isinstance(other, self._constructor):
             return False
         return self._data.equals(other._data)
-            
+
     #----------------------------------------------------------------------
     # Iteration
 


Test patch:
diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py
--- a/pandas/tests/test_strings.py
+++ b/pandas/tests/test_strings.py
@@ -29,6 +29,11 @@ class TestStringMethods(tm.TestCase):
 
     _multiprocess_can_split_ = True
 
+    def test_api(self):
+
+        # GH 6106
+        self.assert_(Series.str is None)
+
     def test_iter(self):
         # GH3638
         strs = 'google', 'wikimedia', 'wikipedia', 'wikitravel'
Repository: pandas-dev/pandas

Issue:
BUG: in HTMLFormatter._write_header(), str() fails on column names in unicode
## IPython snippet reproducing the problem

``` python
import pandas as pd
import numpy as np
df = pd.DataFrame({u'clé1': [u'a', u'a', u'b', u'b', u'a'],
                   u'clé2': [u'1er', u'2ème', u'1er', u'2ème', u'1er'],
                   'données1': np.random.randn(5),
                   'données2': np.random.randn(5)})
df.pivot_table(rows=[u'clé1'], cols=[u'clé2'])
```
## INSTALLED VERSIONS

Python: 2.7.5.final.0
OS: Linux
Release: 2.6.32-358.14.1.el6.x86_64
Processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.13.0
Cython: 0.19.2
Numpy: 1.8.0
Scipy: Not installed
statsmodels: Not installed
    patsy: Not installed
scikits.timeseries: Not installed
dateutil: 2.2
pytz: 2013.9
bottleneck: Not installed
PyTables: Not Installed
    numexpr: Not Installed
matplotlib: Not installed
openpyxl: Not installed
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: Not installed
sqlalchemy: Not installed
lxml: 3.2.5
bs4: Not installed
html5lib: Not installed
bigquery: Not installed
apiclient: Not installed
## Expected behavior

HTML formatted table.
## Seen instead

Warning message in IPython:

```
WARNING: Exception in text/html formatter: 'ascii' codec can't encode character u'\xe9' in position 2: ordinal not in range(128)
```



Discussion:

Resolving patch:
diff --git a/pandas/core/format.py b/pandas/core/format.py
--- a/pandas/core/format.py
+++ b/pandas/core/format.py
@@ -767,7 +767,7 @@ def _column_header():
                                                          levels)):
                 name = self.columns.names[lnum]
                 row = [''] * (row_levels - 1) + ['' if name is None
-                                                 else str(name)]
+                                                 else com.pprint_thing(name)]
 
                 tags = {}
                 j = len(row)


Test patch:
diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py
--- a/pandas/tests/test_format.py
+++ b/pandas/tests/test_format.py
@@ -719,6 +719,14 @@ def test_to_html_index_formatter(self):
 </table>"""
         self.assertEquals(result, expected)
 
+    def test_to_html_regression_GH6098(self):
+        df = DataFrame({u('clé1'): [u('a'), u('a'), u('b'), u('b'), u('a')],
+                           u('clé2'): [u('1er'), u('2ème'), u('1er'), u('2ème'), u('1er')],
+                           'données1': np.random.randn(5),
+                           'données2': np.random.randn(5)})
+        # it works
+        df.pivot_table(rows=[u('clé1')], cols=[u('clé2')])._repr_html_()
+
     def test_nonunicode_nonascii_alignment(self):
         df = DataFrame([["aa\xc3\xa4\xc3\xa4", 1], ["bbbb", 2]])
         rep_str = df.to_string()
Repository: pandas-dev/pandas

Issue:
get_options_data fails when given only the month
if you call this method using only the month, an UnboundedLocalError exception is trown

```
goog_opt.get_options_data(month=3)
```

```
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/data.pyc in _get_option_data(self, month, year, expiry, table_loc, name)
    639 
    640         if month:
--> 641             name += m1 + str(year)[-2:]
    642         setattr(self, name, option_data)
    643         return option_data

UnboundLocalError: local variable 'm1' referenced before assignment
```

Apparently the issue is in here: https://github.com/pydata/pandas/blob/master/pandas/io/data.py#L639



Discussion:

Resolving patch:
diff --git a/pandas/io/data.py b/pandas/io/data.py
--- a/pandas/io/data.py
+++ b/pandas/io/data.py
@@ -632,6 +632,10 @@ def get_options_data(self, month=None, year=None, expiry=None):
     _OPTIONS_BASE_URL = 'http://finance.yahoo.com/q/op?s={sym}'
 
     def _get_option_data(self, month, year, expiry, table_loc, name):
+        if (month is None or year is None) and expiry is None:
+            msg = "You must specify either (`year` and `month`) or `expiry`."
+            raise ValueError(msg)
+
         year, month = self._try_parse_dates(year, month, expiry)
 
         url = self._OPTIONS_BASE_URL.format(sym=self.symbol)


Test patch:
diff --git a/pandas/io/tests/test_data.py b/pandas/io/tests/test_data.py
--- a/pandas/io/tests/test_data.py
+++ b/pandas/io/tests/test_data.py
@@ -266,6 +266,12 @@ def test_get_options_data(self):
             assert len(calls)>1
             assert len(puts)>1
 
+    def test_get_options_data(self):
+
+        # regression test GH6105
+        self.assertRaises(ValueError,self.aapl.get_options_data,month=3)
+        self.assertRaises(ValueError,self.aapl.get_options_data,year=1992)
+
     @network
     def test_get_near_stock_price(self):
         try: