Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
[x] I have checked that this issue has not already been reported.
[x] I have confirmed this bug exists on the latest version of pandas.
[ ] (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
import pandas as pd
dfx = pd.DataFrame({'a':[1,2,3], 'cat':['a', 'b', 'a']}).astype({'cat':'category'})
dfy = pd.DataFrame({'a':[3,4,5], 'cat':['a', 'a', 'a']}).astype({'cat':'category'}) # no 'b' here
dfz=pd.concat([dfx,dfy])
dfz['cat']
Out[55]:
0 a
1 b
2 a
3 a
4 a
5 a
Name: cat, dtype: object
Problem description
I am expecting (erroneously?) that resulting 'cat' column should be the merged categories of 'dfx' and 'dfy'.
Expected Output
dfz['cat']
Out[58]:
0 a
1 b
2 a
3 a
4 a
5 a
Name: cat, dtype: category
Categories (2, object): ['a', 'b']
[x] I have checked that this issue has not already been reported.
[x] I have confirmed this bug exists on the latest version of pandas.
[ ] (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
I am expecting (erroneously?) that resulting 'cat' column should be the merged categories of 'dfx' and 'dfy'.
Expected Output
Output of
pd.show_versions()