Skip to content
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

Unable to store category data in panels #14454

Closed
tonymowers opened this issue Oct 19, 2016 · 3 comments
Closed

Unable to store category data in panels #14454

tonymowers opened this issue Oct 19, 2016 · 3 comments
Labels
API Design Categorical Categorical Data Type

Comments

@tonymowers
Copy link

tonymowers commented Oct 19, 2016

Create a dataframe with a variable of dtype category and then convert to a panel

# A dataframe with a category variable
df = pd.DataFrame({ 'day' : [1,2,3], 'month' : ['a','b','c'], 'dow' : ['mon','mon','thur' ]})
df = df.set_index(['day','month'])
df.dow = df.dow.astype('category')

# Transform to panel and check the dtype
df.to_panel().dtypes
#### Expected Output
dow    category
dtype: object

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 23.0.0
Cython: 0.24
numpy: 1.11.1
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None

The variable was converted from a category to an object when put into a panel

dow object
dtype: object

@jorisvandenbossche
Copy link
Member

Yes, categoricals are currently limited to 1D data (#8709), and therefore not very well supported in panels.

Given that we are not going to develop Panels any further (see #13563), this is probably a "won't fix"

@jreback jreback added this to the No action milestone Oct 20, 2016
@jreback jreback added API Design Categorical Categorical Data Type labels Oct 20, 2016
@jreback
Copy link
Contributor

jreback commented Oct 20, 2016

yep, this is not likely to be implemented.

@jreback jreback closed this as completed Oct 20, 2016
@tonymowers
Copy link
Author

tonymowers commented Oct 20, 2016

Thanks for the response. I'll make a point of leaning on the Panel object less and it also tells me there are probably good alternatives to using Panels in most situations.

@jreback jreback modified the milestones: No action, won't fix Jul 11, 2017
@TomAugspurger TomAugspurger modified the milestones: won't fix, No action Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Categorical Categorical Data Type
Projects
None yet
Development

No branches or pull requests

4 participants