We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import pandas as pd df = pd.DataFrame( data=[1., 2., 3.], columns=pd.MultiIndex.from_tuples( [('A', 'X')], names=['Top', 'Bottom'], ) ) df2 = df.astype({('A', 'X'): 'int'}) print(df.columns.names) print(df2.columns.names)
df2 should have the same column.names as df. What actually happens is that the column.names become [None, None].
df2
column.names
df
[None, None]
If instead the definition of df2 becomes:
df2 = df.astype('int')
Then the expected behavior is observed.
['Top', 'Bottom']
pd.show_versions()
pandas: 0.22.0 pytest: 4.6.2 pip: 19.1.1 setuptools: 41.0.1 Cython: 0.28.5 numpy: 1.14.5 scipy: 1.0.1 pyarrow: None xarray: 0.11.3 IPython: 5.8.0 sphinx: 1.8.5 patsy: 0.5.1 dateutil: 2.8.0 pytz: 2019.1 blosc: None bottleneck: 1.2.1 tables: 3.4.4 numexpr: 2.6.9 feather: None matplotlib: 2.2.3 openpyxl: 2.6.2 xlrd: 1.2.0 xlwt: 1.3.0 xlsxwriter: 1.1.8 lxml: 4.2.4 bs4: 4.7.1 html5lib: 1.0.1 sqlalchemy: 1.3.5 pymysql: None psycopg2: 2.7.5 (dt dec pq3 ext lo64) jinja2: 2.10.1 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
The text was updated successfully, but these errors were encountered:
This is a pretty old version of pandas - can you try on 0.25?
Sorry, something went wrong.
This is a dupe of #19920 and was fixed as part of 0.23.0.
No branches or pull requests
Code Sample, a copy-pastable example if possible
Problem description
df2
should have the samecolumn.names
asdf
. What actually happens is that thecolumn.names
become[None, None]
.If instead the definition of
df2
becomes:Then the expected behavior is observed.
Expected Output
['Top', 'Bottom']
Output of
pd.show_versions()
pandas: 0.22.0
pytest: 4.6.2
pip: 19.1.1
setuptools: 41.0.1
Cython: 0.28.5
numpy: 1.14.5
scipy: 1.0.1
pyarrow: None
xarray: 0.11.3
IPython: 5.8.0
sphinx: 1.8.5
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 2.2.3
openpyxl: 2.6.2
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.8
lxml: 4.2.4
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.5
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: