Skip to content

ENH: df.astype could accept a dict of {col: type} #7271

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

Closed
TomAugspurger opened this issue May 29, 2014 · 2 comments
Closed

ENH: df.astype could accept a dict of {col: type} #7271

TomAugspurger opened this issue May 29, 2014 · 2 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement
Milestone

Comments

@TomAugspurger
Copy link
Contributor

This would be consistent with other pandas methods.

The reason I'm running into it is having some NaNs scattered across some int and bool columns, which converts to float / objects. If I discard those NaNs, it would be nice to do

df = df.astype({'my_bool', 'bool', 'my_int': 'int'})

instead of

df['my_bool'] = df.my_bool.astype('bool')
df['my_int'] = df.my_int.astype('int')
@TomAugspurger TomAugspurger added this to the 0.15.0 milestone May 29, 2014
@jreback
Copy link
Contributor

jreback commented May 29, 2014

that's a nice idea!

@hayd
Copy link
Contributor

hayd commented May 29, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Enhancement
Projects
None yet
3 participants