Skip to content

BUG: concat on axis=0 with categorical #10177

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
jreback opened this issue May 20, 2015 · 4 comments
Closed

BUG: concat on axis=0 with categorical #10177

jreback opened this issue May 20, 2015 · 4 comments
Labels
Bug Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 20, 2015

xref #9426, fixed in #9597
axis=1 is ok

df1 = pandas.DataFrame(numpy.random.randn(6, 3), columns=["a", "b", "c"])
df2 = pandas.DataFrame(numpy.random.randn(7, 4), columns=["g", "h", "a", "c"])
df2['h'] = pandas.Series(pandas.Categorical(["one", "one", "two", "one", "two", "two", "one"]))
df = pandas.concat((df1, df2))
@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Categorical Categorical Data Type Difficulty Intermediate labels May 20, 2015
@jreback jreback added this to the 0.17.0 milestone May 20, 2015
@sebp
Copy link

sebp commented May 20, 2015

Note that it works if the "h" column is of object dtype:

          a         b         c         g    h
0 -0.673360 -0.795002  0.842495       NaN  NaN
1 -0.387503  1.093774 -1.138618       NaN  NaN
2 -1.108967 -0.339614  0.563358       NaN  NaN
3 -0.540412  1.299025  0.783089       NaN  NaN
4  1.796500 -1.630790 -1.039589       NaN  NaN
5 -0.427310 -0.149733  1.796212       NaN  NaN
0  0.087274       NaN  0.773546 -0.342498  one
1  0.346405       NaN -0.066082 -0.002910  one
2  1.496320       NaN  0.939827 -1.046683  two
3  3.248297       NaN -0.883009 -2.142893  one
4  1.315608       NaN  1.048771 -1.284582  two
5 -0.785210       NaN  0.158105  0.814332  two
6  0.322257       NaN -0.352677 -0.385390  one

@jreback
Copy link
Contributor Author

jreback commented May 20, 2015

@sebp want to give a shot at a fix?

@sebp
Copy link

sebp commented May 20, 2015

@jreback sure, I can have a look at it if I find some time.

@jreback
Copy link
Contributor Author

jreback commented Jun 27, 2015

closed by #10179

@jreback jreback closed this as completed Jun 27, 2015
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

No branches or pull requests

2 participants