Skip to content

BUG: DataFrame.astype with category dtype #16983

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
rhaps0dy opened this issue Jul 16, 2017 · 0 comments
Closed

BUG: DataFrame.astype with category dtype #16983

rhaps0dy opened this issue Jul 16, 2017 · 0 comments
Labels
Bug Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@rhaps0dy
Copy link

rhaps0dy commented Jul 16, 2017

Code Sample, a copy-pastable example if possible

import pandas as pd
df = pd.DataFrame({'a': list('aab'), 'b': list('bba')})
df.a = df.a.astype('category')
df.b = df.b.astype('category')
df.astype('object')
# ValueError: Wrong number of dimensions

related failure

In [1]: df = pd.DataFrame({
   ...:     'a': ['foo', 'bar', None],
   ...:     'b': ['baz', 'quux', None]
   ...: }, dtype='category')
   ...: df
   ...: 
Out[1]: 
     a     b
0  foo   baz
1  bar  quux
2  NaN   NaN

In [2]: df.where(df.isnull(), None)
---------------------------------------------------------------------------
ValueError: Wrong number of items passed 3, placement implies 1

Problem description

Object dataframes can contain any Python object so anything should be convertible to them. Split off of #16979.

@gfyoung gfyoung added Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions Bug labels Jul 16, 2017
@jreback jreback added this to the Next Major Release milestone Jul 16, 2017
@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants