Closed
Description
Issues:
-
Index.difference
andsymmetric_difference
raise for mixed types (solved by BUG/PERF: Sort mixed-int in Py3, fix Index.difference #13514) -
Index._get_consensus_name
incorrectly returns an empty index (solved by BUG/PERF: Sort mixed-int in Py3, fix Index.difference #13514) - bug in
Index.union
for non-unique indexes (see comment) - bug in
Index.intersection
for non-unique indexes (same comment) - inconsistent sorting in of mixed-int Indexes in python2 (see comment)
Index.difference
and symmetric_difference
raise for mixed types
Code Sample, a copy-pastable example if possible
idx1 = pd.Index([0, 1, 'A', 'B'])
idx2 = pd.Index([0, 2, 'A', 'C'])
idx1.difference(idx2)
...
File "/usr/local/lib64/python3.5/site-packages/pandas/indexes/base.py", line 1861, in difference
theDiff = sorted(set(self) - set(other))
TypeError: unorderable types: str() < int()
idx1.symmetric_difference(idx2)
...
File "/usr/local/lib64/python3.5/site-packages/pandas/indexes/base.py", line 1861, in difference
theDiff = sorted(set(self) - set(other))
TypeError: unorderable types: str() < int()
But union
and intersection
work:
idx1.union(idx2)
Out[14]: Index([0, 1, 'A', 'B', 2, 'C'], dtype='object')
idx1.intersection(idx2)
Out[15]: Index([0, 'A'], dtype='object')
Expected Output
idx1.difference(idx2)
Out[]: Index([1, 'B'], dtype='object')
idx1.symmetric_difference(idx2)
Out[]: Index([1, 'B', 2, 'C'], dtype='object')
output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: 4a6621fcaa9a3b98172b90a69de574ec94b108df
python: 3.5.1.final.0
python-bits: 64
OS: Linux
machine: x86_64
byteorder: little
pandas: 0.18.1
...