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

Issue:
DOC: source links in API reference
For example, from numpy.
http://docs.scipy.org/doc/numpy/reference/generated/numpy.take.html

I don't know enough about sphinx to know how hard/easy this is, but it may be nice. 



Discussion:
Can likely do exactly what numpy does here - 
https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
using
http://www.sphinx-doc.org/en/stable/ext/linkcode.html

Yes, we can certainly do something like that. We only have quite some dynamically generated methods, so not sure how it works for those (but at least it can work for the others).


Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -13,6 +13,7 @@
 import sys
 import os
 import re
+import inspect
 from pandas.compat import u, PY3
 
 # If extensions (or modules to document with autodoc) are in another directory,
@@ -47,6 +48,7 @@
               'sphinx.ext.coverage',
               'sphinx.ext.pngmath',
               'sphinx.ext.ifconfig',
+              'sphinx.ext.linkcode',
               ]
 
 
@@ -424,6 +426,55 @@ def get_items(self, names):
         return items
 
 
+# based on numpy doc/source/conf.py
+def linkcode_resolve(domain, info):
+    """
+    Determine the URL corresponding to Python object
+    """
+    if domain != 'py':
+        return None
+
+    modname = info['module']
+    fullname = info['fullname']
+
+    submod = sys.modules.get(modname)
+    if submod is None:
+        return None
+
+    obj = submod
+    for part in fullname.split('.'):
+        try:
+            obj = getattr(obj, part)
+        except:
+            return None
+
+    try:
+        fn = inspect.getsourcefile(obj)
+    except:
+        fn = None
+    if not fn:
+        return None
+
+    try:
+        source, lineno = inspect.getsourcelines(obj)
+    except:
+        lineno = None
+
+    if lineno:
+        linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
+    else:
+        linespec = ""
+
+    fn = os.path.relpath(fn, start=os.path.dirname(pandas.__file__))
+
+    if '+' in pandas.__version__:
+        return "http://github.com/pydata/pandas/blob/master/pandas/%s%s" % (
+            fn, linespec)
+    else:
+        return "http://github.com/pydata/pandas/blob/v%s/pandas/%s%s" % (
+            pandas.__version__, fn, linespec)
+
+
 # remove the docstring of the flags attribute (inherited from numpy ndarray)
 # because these give doc build errors (see GH issue 5331)
 def remove_flags_docstring(app, what, name, obj, options, lines):


Test patch:
Repository: pandas-dev/pandas

Issue:
pandas.DataFrame.unstack() documentation example has errors
The last part of the documentation says

``` python
>>> df = s.unstack(level=0)
>>> df.unstack()
one  a  1.
     b  3.
two  a  2.
     b  4.
```

although we'd have

``` python
>>> import pandas as pd
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
...                                     ('two', 'a'), ('two', 'b')])
>>> import numpy as np
>>> s = pd.Series(np.arange(1.0, 5.0), index=index)
>>> s
one  a    1.0
     b    2.0
two  a    3.0
     b    4.0
dtype: float64
>>> s.unstack(level=-1)
       a    b
one  1.0  2.0
two  3.0  4.0
>>> s.unstack(level=0)
   one  two
a  1.0  3.0
b  2.0  4.0
>>> df = s.unstack(level=0)
>>> df.unstack()
one  a    1.0
     b    2.0
two  a    3.0
     b    4.0
dtype: float64
```



Discussion:
Hmm, I thought this was already fixed before, but apparently not ..

PR to fix this very welcome!

Seems that I corrected one of the examples a long time ago, but not that last one :-) https://github.com/pydata/pandas/pull/4776


Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -3805,28 +3805,29 @@ def unstack(self, level=-1):
         ...                                    ('two', 'a'), ('two', 'b')])
         >>> s = pd.Series(np.arange(1.0, 5.0), index=index)
         >>> s
-        one  a   1
-             b   2
-        two  a   3
-             b   4
+        one  a   1.0
+             b   2.0
+        two  a   3.0
+             b   4.0
         dtype: float64
 
         >>> s.unstack(level=-1)
              a   b
-        one  1  2
-        two  3  4
+        one  1.0  2.0
+        two  3.0  4.0
 
         >>> s.unstack(level=0)
            one  two
-        a  1   3
-        b  2   4
+        a  1.0   3.0
+        b  2.0   4.0
 
         >>> df = s.unstack(level=0)
         >>> df.unstack()
-        one  a  1.
-             b  3.
-        two  a  2.
-             b  4.
+        one  a  1.0
+             b  2.0
+        two  a  3.0
+             b  4.0
+        dtype: float64
 
         Returns
         -------


Test patch:
Repository: pandas-dev/pandas

Issue:
Re: DataFrame.to_csv(quoting=csv.QUOTE_NONNUMERIC) quotes numeric values
As per the issue outlined in #12922, applying a float_format or having a NaN value with a float would continue to treat the value as non-numeric when quoting=csv.QUOTE_NONNUMERIC is used. The format string resulting in the float treated like a string should be documented as per @jreback in #12922.



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
@@ -1345,7 +1345,9 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
             The newline character or character sequence to use in the output
             file
         quoting : optional constant from csv module
-            defaults to csv.QUOTE_MINIMAL
+            defaults to csv.QUOTE_MINIMAL. If you have set a `float_format`
+            then floats are comverted to strings and thus csv.QUOTE_NONNUMERIC
+            will treat them as non-numeric
         quotechar : string (length 1), default '\"'
             character used to quote fields
         doublequote : boolean, default True


Test patch:
Repository: pandas-dev/pandas

Issue:
DOC: Series.map na_action confusion
A user on [stackoverflow](http://stackoverflow.com/questions/39461328/in-pandas-what-does-the-na-action-parameter-to-series-map-do/39461948?noredirect=1#comment66278752_39461948) was confused about the use of na_action in Series.map and so I came up with a simple example to explain it. @jorisvandenbossche asked me to submit a PR, so I created this issue to log the issue and will submit a PR now. 



Discussion:

Resolving patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -2099,10 +2099,19 @@ def map(self, arg, na_action=None):
         ----------
         arg : function, dict, or Series
         na_action : {None, 'ignore'}
-            If 'ignore', propagate NA values
+            If 'ignore', propagate NA values, without passing them to the
+            mapping function
+
+        Returns
+        -------
+        y : Series
+            same index as caller
 
         Examples
         --------
+
+        Map inputs to outputs
+
         >>> x
         one   1
         two   2
@@ -2118,10 +2127,27 @@ def map(self, arg, na_action=None):
         two   bar
         three baz
 
-        Returns
-        -------
-        y : Series
-            same index as caller
+        Use na_action to control whether NA values are affected by the mapping
+        function.
+
+        >>> s = pd.Series([1, 2, 3, np.nan])
+
+        >>> s2 = s.map(lambda x: 'this is a string {}'.format(x),
+                       na_action=None)
+        0    this is a string 1.0
+        1    this is a string 2.0
+        2    this is a string 3.0
+        3    this is a string nan
+        dtype: object
+
+        >>> s3 = s.map(lambda x: 'this is a string {}'.format(x),
+                       na_action='ignore')
+        0    this is a string 1.0
+        1    this is a string 2.0
+        2    this is a string 3.0
+        3                     NaN
+        dtype: object
+
         """
 
         if is_extension_type(self.dtype):


Test patch:
Repository: pandas-dev/pandas

Issue:
TST: 3.5 c-locale
https://travis-ci.org/pydata/pandas/jobs/161159736

xref #14114, #12337

```
======================================================================
ERROR: test_to_latex_filename (pandas.tests.formats.test_format.TestDataFrameFormatting)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/tests/formats/test_format.py", line 2825, in test_to_latex_filename
    df.to_latex(path)
  File "/home/travis/build/pydata/pandas/pandas/core/frame.py", line 1661, in to_latex
    encoding=encoding)
  File "/home/travis/build/pydata/pandas/pandas/formats/format.py", line 662, in to_latex
    latex_renderer.write_result(f)
  File "/home/travis/build/pydata/pandas/pandas/formats/format.py", line 906, in write_result
    buf.write(' & '.join(crow))
UnicodeEncodeError: 'ascii' codec can't encode character '\xdf' in position 7: ordinal not in range(128)
----------------------------------------------------------------------
Ran 10273 tests in 375.734s
```

cc @nbonnotte 



Discussion:
cc @nbonnotte 


Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -1635,7 +1635,8 @@ def to_latex(self, buf=None, columns=None, col_space=None, header=True,
             When set to False prevents from escaping latex special
             characters in column names.
         encoding : str, default None
-            Default encoding is ascii in Python 2 and utf-8 in Python 3
+            A string representing the encoding to use in the output file,
+            defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
         decimal : string, default '.'
             Character recognized as decimal separator, e.g. ',' in Europe
 
diff --git a/pandas/formats/format.py b/pandas/formats/format.py
--- a/pandas/formats/format.py
+++ b/pandas/formats/format.py
@@ -654,6 +654,9 @@ def to_latex(self, column_format=None, longtable=False, encoding=None):
         latex_renderer = LatexFormatter(self, column_format=column_format,
                                         longtable=longtable)
 
+        if encoding is None:
+            encoding = 'ascii' if compat.PY2 else 'utf-8'
+
         if hasattr(self.buf, 'write'):
             latex_renderer.write_result(self.buf)
         elif isinstance(self.buf, compat.string_types):


Test patch:
diff --git a/pandas/tests/formats/test_format.py b/pandas/tests/formats/test_format.py
--- a/pandas/tests/formats/test_format.py
+++ b/pandas/tests/formats/test_format.py
@@ -2823,7 +2823,7 @@ def test_to_latex_filename(self):
         if compat.PY3:  # python3: pandas default encoding is utf-8
             with tm.ensure_clean('test.tex') as path:
                 df.to_latex(path)
-                with codecs.open(path, 'r') as f:
+                with codecs.open(path, 'r', encoding='utf-8') as f:
                     self.assertEqual(df.to_latex(), f.read())
         else:
             # python2 default encoding is ascii, so an error should be raised
Repository: pandas-dev/pandas

Issue:
Conflicting documentation about index uniqueness
The page http://pandas.pydata.org/pandas-docs/dev/generated/pandas.Series.html says:

> index : array-like or Index (1d)
> Values must be unique and hashable, same length as data. 

A little bit earlier the same page says: 

> Labels need not be unique but must be any hashable type.  

Other pages also mention non-unique index support (e.g. http://pandas.pydata.org/pandas-docs/dev/dsintro.html) It looks like `index` description should read:

> index : array-like or Index (1d)
> Values must be hashable, same length as data. Non-unique index values are allowed. 



Discussion:
yep looks like hasn't been update
pls do a pull-request with those changes

@bgbg pull-request for this?


Resolving patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -102,11 +102,11 @@ class Series(base.IndexOpsMixin, strings.StringAccessorMixin,
     """
     One-dimensional ndarray with axis labels (including time series).
 
-    Labels need not be unique but must be any hashable type. The object
+    Labels need not be unique but must be a hashable type. The object
     supports both integer- and label-based indexing and provides a host of
     methods for performing operations involving the index. Statistical
     methods from ndarray have been overridden to automatically exclude
-    missing data (currently represented as NaN)
+    missing data (currently represented as NaN).
 
     Operations between Series (+, -, /, *, **) align values based on their
     associated index values-- they need not be the same length. The result
@@ -117,8 +117,8 @@ class Series(base.IndexOpsMixin, strings.StringAccessorMixin,
     data : array-like, dict, or scalar value
         Contains data stored in Series
     index : array-like or Index (1d)
-        Values must be unique and hashable, same length as data. Index
-        object (or other iterable of same length as data) Will default to
+        Values must be hashable and have the same length as `data`.
+        Non-unique index values are allowed. Will default to
         RangeIndex(len(data)) if not provided. If both a dict and index
         sequence are used, the index will override the keys found in the
         dict.


Test patch:
Repository: pandas-dev/pandas

Issue:
DEV: Update merge-pr.py script given repo rename
This is still pointing to pydata/pandas.git -- it is working fine presumably because of magic redirection



Discussion:

Resolving patch:
diff --git a/scripts/merge-py.py b/scripts/merge-py.py
--- a/scripts/merge-py.py
+++ b/scripts/merge-py.py
@@ -46,8 +46,8 @@
 # Remote name where results pushed
 PUSH_REMOTE_NAME = os.environ.get("PUSH_REMOTE_NAME", "upstream")
 
-GITHUB_BASE = "https://github.com/pydata/" + PROJECT_NAME + "/pull"
-GITHUB_API_BASE = "https://api.github.com/repos/pydata/" + PROJECT_NAME
+GITHUB_BASE = "https://github.com/pandas-dev/" + PROJECT_NAME + "/pull"
+GITHUB_API_BASE = "https://api.github.com/repos/pandas-dev/" + PROJECT_NAME
 
 # Prefix added to temporary branches
 BRANCH_PREFIX = "PR_TOOL"
@@ -124,7 +124,7 @@ def clean_up():
         run_cmd("git branch -D %s" % branch)
 
 
-# merge the requested PR and return the merge hash
+# Merge the requested PR and return the merge hash
 def merge_pr(pr_num, target_ref):
 
     pr_branch_name = "%s_MERGE_PR_%s" % (BRANCH_PREFIX, pr_num)
@@ -244,13 +244,6 @@ def fix_version_from_branch(branch, versions):
         branch_ver = branch.replace("branch-", "")
         return filter(lambda x: x.name.startswith(branch_ver), versions)[-1]
 
-
-# branches = get_json("%s/branches" % GITHUB_API_BASE)
-# branch_names = filter(lambda x: x.startswith("branch-"),
-#                       [x['name'] for x in branches])
-# Assumes branch names can be sorted lexicographically
-# latest_branch = sorted(branch_names, reverse=True)[0]
-
 pr_num = input("Which pull request would you like to merge? (e.g. 34): ")
 pr = get_json("%s/pulls/%s" % (GITHUB_API_BASE, pr_num))
 


Test patch:
Repository: pandas-dev/pandas

Issue:
DOC: give read_clipboard a signature
Wouldn't necessarily need to add everything that `read_table` accepts, but at minimum adding a couple common ones like `delim_whitespace` and `sep` would make it nicer for argument completion in interactive use.

https://github.com/pydata/pandas/blob/master/pandas/io/clipboard.py#L6



Discussion:
Actually it is:) PR is appreciated.


Resolving patch:
diff --git a/pandas/io/clipboard.py b/pandas/io/clipboard.py
--- a/pandas/io/clipboard.py
+++ b/pandas/io/clipboard.py
@@ -3,12 +3,16 @@
 from pandas.compat import StringIO
 
 
-def read_clipboard(**kwargs):  # pragma: no cover
-    """
+def read_clipboard(sep='\s+', **kwargs):  # pragma: no cover
+    r"""
     Read text from clipboard and pass to read_table. See read_table for the
     full argument list
 
-    If unspecified, `sep` defaults to '\s+'
+    Parameters
+    ----------
+    sep : str, default '\s+'.
+        A string or regex delimiter. The default of '\s+' denotes
+        one or more whitespace characters.
 
     Returns
     -------
@@ -29,7 +33,7 @@ def read_clipboard(**kwargs):  # pragma: no cover
         except:
             pass
 
-    # Excel copies into clipboard with \t seperation
+    # Excel copies into clipboard with \t separation
     # inspect no more then the 10 first lines, if they
     # all contain an equal number (>0) of tabs, infer
     # that this came from excel and set 'sep' accordingly
@@ -43,12 +47,12 @@ def read_clipboard(**kwargs):  # pragma: no cover
 
     counts = set([x.lstrip().count('\t') for x in lines])
     if len(lines) > 1 and len(counts) == 1 and counts.pop() != 0:
-        kwargs['sep'] = '\t'
+        sep = '\t'
 
-    if kwargs.get('sep') is None and kwargs.get('delim_whitespace') is None:
-        kwargs['sep'] = '\s+'
+    if sep is None and kwargs.get('delim_whitespace') is None:
+        sep = '\s+'
 
-    return read_table(StringIO(text), **kwargs)
+    return read_table(StringIO(text), sep=sep, **kwargs)
 
 
 def to_clipboard(obj, excel=None, sep=None, **kwargs):  # pragma: no cover


Test patch:
diff --git a/pandas/io/tests/test_clipboard.py b/pandas/io/tests/test_clipboard.py
--- a/pandas/io/tests/test_clipboard.py
+++ b/pandas/io/tests/test_clipboard.py
@@ -71,6 +71,8 @@ def check_round_trip_frame(self, data_type, excel=None, sep=None):
     def test_round_trip_frame_sep(self):
         for dt in self.data_types:
             self.check_round_trip_frame(dt, sep=',')
+            self.check_round_trip_frame(dt, sep='\s+')
+            self.check_round_trip_frame(dt, sep='|')
 
     def test_round_trip_frame_string(self):
         for dt in self.data_types:
Repository: pandas-dev/pandas

Issue:
read_excel with sheetname=None or sheetname=[0,1,”Sheet5”] should preserve sheets order
Hello,

I noticed in http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html#pandas.read_excel
that `read_excel` can have a parameter `sheetname`set to `None` or a to a `list`

In such a case a dictionary of `DataFrame` is returned.

Maybe it should output an `OrderedDict` of `DataFrame` to preserve sheets order.

Kind regards



Discussion:

Resolving patch:
diff --git a/pandas/io/excel.py b/pandas/io/excel.py
--- a/pandas/io/excel.py
+++ b/pandas/io/excel.py
@@ -21,7 +21,7 @@
 from pandas.tseries.period import Period
 from pandas import json
 from pandas.compat import (map, zip, reduce, range, lrange, u, add_metaclass,
-                           string_types)
+                           string_types, OrderedDict)
 from pandas.core import config
 from pandas.formats.printing import pprint_thing
 import pandas.compat as compat
@@ -418,9 +418,9 @@ def _parse_cell(cell_contents, cell_typ):
             sheets = [sheetname]
 
         # handle same-type duplicates.
-        sheets = list(set(sheets))
+        sheets = list(OrderedDict.fromkeys(sheets).keys())
 
-        output = {}
+        output = OrderedDict()
 
         for asheetname in sheets:
             if verbose:


Test patch:
diff --git a/pandas/io/tests/data/test_multisheet.xls b/pandas/io/tests/data/test_multisheet.xls
Binary files a/pandas/io/tests/data/test_multisheet.xls and b/pandas/io/tests/data/test_multisheet.xls differ
diff --git a/pandas/io/tests/data/test_multisheet.xlsm b/pandas/io/tests/data/test_multisheet.xlsm
Binary files a/pandas/io/tests/data/test_multisheet.xlsm and b/pandas/io/tests/data/test_multisheet.xlsm differ
diff --git a/pandas/io/tests/data/test_multisheet.xlsx b/pandas/io/tests/data/test_multisheet.xlsx
Binary files a/pandas/io/tests/data/test_multisheet.xlsx and b/pandas/io/tests/data/test_multisheet.xlsx differ
diff --git a/pandas/io/tests/test_excel.py b/pandas/io/tests/test_excel.py
--- a/pandas/io/tests/test_excel.py
+++ b/pandas/io/tests/test_excel.py
@@ -379,8 +379,12 @@ def test_reading_all_sheets(self):
         # See PR #9450
         basename = 'test_multisheet'
         dfs = self.get_exceldf(basename, sheetname=None)
-        expected_keys = ['Alpha', 'Beta', 'Charlie']
+        # ensure this is not alphabetical to test order preservation
+        expected_keys = ['Charlie', 'Alpha', 'Beta']
         tm.assert_contains_all(expected_keys, dfs.keys())
+        # Issue 9930
+        # Ensure sheet order is preserved
+        tm.assert_equal(expected_keys, list(dfs.keys()))
 
     def test_reading_multiple_specific_sheets(self):
         # Test reading specific sheetnames by specifying a mixed list
Repository: pandas-dev/pandas

Issue:
Spelling Error in docs for to_json
#### A small, complete example of the issue

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_json.html

`default` is spelled `defalut`



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
@@ -1066,7 +1066,7 @@ def to_json(self, path_or_buf=None, orient=None, date_format='epoch',
             Handler to call if object cannot otherwise be converted to a
             suitable format for JSON. Should receive a single argument which is
             the object to convert and return a serialisable object.
-        lines : boolean, defalut False
+        lines : boolean, default False
             If 'orient' is 'records' write out line delimited json format. Will
             throw ValueError if incorrect 'orient' since others are not list
             like.


Test patch:
Repository: pandas-dev/pandas

Issue:
floats and ints missing as acceptable arguments for pandas.to_datetime in API Reference
#### A small, complete example of the issue

http://pandas.pydata.org/pandas-docs/version/0.19.0/generated/pandas.to_datetime.html says:
> **arg** : _string, datetime, list, tuple, 1-d array, Series_

While http://pandas.pydata.org/pandas-docs/version/0.19.0/timeseries.html#epoch-timestamps says that `int`s and `float`s are accepted as well.

#### Expected Output

`int` and `float` to be in the list

#### Output of ``pd.show_versions()``

```
pandas: 0.19.0
```

<details>

```
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.0
nose: None
pip: 7.1.0
setuptools: 18.0.1
Cython: None
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None
```

</details>


Discussion:
That is correct. Pull request to update the docstring is very welcome!

I would like to work on the issue. Which files need updating?

you need to look for the source of the `to_datetime` function, this is located in tseries/tools (you can inspect the function to see that, just type `pd.to_datetime` in a console)

I would like to take this up. Just one doubt that I have to just update the doc string of to_datetime function to include integer and float as well ?
yep

Resolving patch:
diff --git a/pandas/tseries/tools.py b/pandas/tseries/tools.py
--- a/pandas/tseries/tools.py
+++ b/pandas/tseries/tools.py
@@ -183,7 +183,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
 
     Parameters
     ----------
-    arg : string, datetime, list, tuple, 1-d array, Series
+    arg : integer, float, string, datetime, list, tuple, 1-d array, Series
 
         .. versionadded: 0.18.1
 


Test patch: