df1=pd.DataFrame({'categorical':['A','A','B'],'i':[1,2,3]})
df1['categorical']=df1['categorical'].astype('category')
df2=pd.DataFrame({'notcategorical':['A','A','B'],'i':[1,2,3]})
df1.dtypes,df2.dtypes
#shows categorical type

#But:
df3=pd.merge(df1,df2,on='i')
df3.dtypes
#categorical now an object type?

Problem description

Merging a dataframe containing a categorical column results in that column losing its category type in the merged dataframe.

Expected Output

The category type of column is preserved in the merged output dataframe.

Version

pandas: 0.19.2

Comment From: jorisvandenbossche

@psychemedia Thanks for the report, this is indeed a bug, and already reported as https://github.com/pandas-dev/pandas/issues/10409