-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Can't mix tuples and strings in column names with Numpy>=1.24 #50372
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
Comments
I performed a few tests and it seems that just changing ( keyarr = com.asarray_tuplesafe(keyarr) into try:
keyarr = com.asarray_tuplesafe(keyarr)
except ValueError:
keyarr = com.asarray_tuplesafe(keyarr, dtype=_dtype_obj) will solve this issue. EDIT: The lines are given for the commit |
moving off the 2.0 milestone |
This looks to work on main now. Could use a test |
I would love to take this as my first issue @mroeschke |
Hi @mroeschke @adrien-berchet I've tried and uploaded a test for this issue. |
Hi @DRiXD |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Here is the reported error:
Issue Description
When mixing tuples and strings as column names, it is no more possible to select columns with mixed name types (e.g.
df_flat[[("a", "aa"), "new_single_index"]]
).Expected Behavior
Selectin columns with both tuple and string names, i.e.
df_flat[[("a", "aa"), "new_single_index"]]
in the given example, should work.Installed Versions
pandas : 2.0.0.dev0+975.gca0434994e
numpy : 1.24.0
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
Cython : None
pytest : 7.2.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.7.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : None
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: