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

BUG: concat with categorical keys doesn't preserve categorical dtype #14016

Open
pijucha opened this issue Aug 16, 2016 · 1 comment
Open

BUG: concat with categorical keys doesn't preserve categorical dtype #14016

pijucha opened this issue Aug 16, 2016 · 1 comment
Labels
Bug Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@pijucha
Copy link
Contributor

pijucha commented Aug 16, 2016

This is a follow-up issue to #13854.

Code Sample, a copy-pastable example if possible

cidx = pd.CategoricalIndex(['y', 'x'], categories=list("xyz"), ordered=True)
df = pd.DataFrame([[10, 11, 12]])

pd.concat([df, df], keys=cidx).index.levels[0]
Out[32]: Index(['y', 'x'], dtype='object')

Expected Output

CategoricalIndex(['y', 'x'], categories=['x', 'y', 'z'], ordered=True, dtype='category')

I decided to put it separately because a fix requires more changes than just a factorization introduced in #13854.

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Categorical Categorical Data Type Difficulty Intermediate labels Aug 17, 2016
@jreback jreback added this to the Next Major Release milestone Aug 17, 2016
@jreback jreback changed the title concat with categorical keys doesn't preserve categorical dtype BUG: concat with categorical keys doesn't preserve categorical dtype Aug 17, 2016
@tom-bird
Copy link
Contributor

Had a pop at this. Let me know if any issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants