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
Setup:
In [2]: df = pd.DataFrame(data=np.random.randint(5, size=(3, 4)), ...: columns=pd.UInt64Index(range(500, 504), name='foo')) ...: In [3]: df Out[3]: foo 500 501 502 503 0 4 4 2 1 1 0 2 3 1 2 1 4 0 0 In [4]: df.columns Out[4]: UInt64Index([500, 501, 502, 503], dtype='uint64', name='foo')
Using .astype(dict) loses column metadata:
.astype(dict)
In [5]: df = df.astype({500: 'float64', 501: 'uint64'}) In [6]: df.columns Out[6]: Int64Index([500, 501, 502, 503], dtype='int64')
Column metadata is lost: the name has been removed and it has been cast from UInt64Index to Int64Index.
name
UInt64Index
Int64Index
I'd expect the columns post-astype to be the same as pre-astype.
astype
The text was updated successfully, but these errors were encountered:
xref #18099 (comment)
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
Setup:
Using
.astype(dict)
loses column metadata:Problem description
Column metadata is lost: the
name
has been removed and it has been cast fromUInt64Index
toInt64Index
.Expected Output
I'd expect the columns post-
astype
to be the same as pre-astype
.The text was updated successfully, but these errors were encountered: