-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError for mixed-type indices in python3 #20900
Comments
I am currently using this workaround that works for my type of indices (ints and strings). I also posted the problem on Stackoverflow.
|
FYI, the example in your original post doesn't run because I think we deliberately choose to follow how the language does things here. NumPy does the same ("sorts" on Py2, raises on Py3). |
Fixed!
I agree that the new ordering policy in python3 is a global change that not necessarily needs to be compensated for in all cases. However, as the index is represented internally by a The alternative would be to prevent mixed-type indices all the way. Or to provide a cook-book recipe on how to deal with mixed-type indices. |
Here is an example with mixed-type indices that requires a table to be lex-sorted and currently fails on pandas3.
|
this is using pandas in a very non-idiomatic way as mixed types are not easily represented, except by object type. that said, the sorting mechanisms internally for object types could use |
This looks like a duplicate of #17010. Closing |
Code Sample, a copy-pastable example if possible
Problem description
The code above works in python2. However, in python3 a
TypeError
is raised:The reason for this is described here: mixed-type sequencing cannot be sorted anymore just like this.
Expected Output
No exception when calling
sort_index
in python3.Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
pandas: 0.22.0
pytest: None
pip: 10.0.0
setuptools: 39.0.1
Cython: None
numpy: 1.14.2
scipy: 1.0.1
pyarrow: None
xarray: None
IPython: 6.3.1
sphinx: None
patsy: None
dateutil: 2.7.2
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: