Skip to content

BUG: duplicate indexing on non-integer index with positional indexers failing in py3 #13427

Closed
@alexanderwhatley

Description

@alexanderwhatley

Code Sample, a copy-pastable example if possible

df = pd.DataFrame({"a" : [0,1,2], "b" : [1,2,3]})
df[["a", "a"]].apply(lambda x: x[0] + x[1], axis = 1)

Expected Output

0 0
1 2
2 4
dtype: int64

output of pd.show_versions()

Traceback (most recent call last):
File "C:\Users\Alexander\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 1980, in get_value
tz=getattr(series.dtype, 'tz', None))
File "pandas\index.pyx", line 103, in pandas.index.IndexEngine.get_value (pandas\index.c:3332)
File "pandas\index.pyx", line 111, in pandas.index.IndexEngine.get_value (pandas\index.c:3035)
File "pandas\index.pyx", line 154, in pandas.index.IndexEngine.get_loc (pandas\index.c:3955)
File "pandas\index.pyx", line 169, in pandas.index.IndexEngine._get_loc_duplicates (pandas\index.c:4236)
TypeError: unorderable types: str() > int()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Alexander\Anaconda3\lib\site-packages\pandas\core\frame.py", line 4061, in apply
return self._apply_standard(f, axis, reduce=reduce)
File "C:\Users\Alexander\Anaconda3\lib\site-packages\pandas\core\frame.py", line 4157, in _apply_standard
results[i] = func(v)
File "", line 1, in
File "C:\Users\Alexander\Anaconda3\lib\site-packages\pandas\core\series.py", line 583, in getitem
result = self.index.get_value(self, key)
File "C:\Users\Alexander\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 2000, in get_value
raise IndexError(key)
IndexError: (0, 'occurred at index 0')

This is the error I get when running on Python 3.5.1/Pandas 0.18.1 on Windows. I get the expected output on Linux running Python 2.7.11/Pandas 0.18.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions