I am not 100% sure if this is a bug, but it generates very unexpected behaviour! Essentially, if columns are of type Categorical, selecting a single one using df[column_name] a DataFrame is returned, unlike for columns of other types, for which a Series would be returned.

Code Sample, a copy-pastable example if possible

print pd.DataFrame([[1,2]], columns=['a','b'])['a'].__class__
print pd.DataFrame([[1,2]], columns=pd.Categorical(['a','b']))['a'].__class__

produces


<class 'pandas.core.series.Series'>  <--- Ok....
<class 'pandas.core.frame.DataFrame'> <----- What?!

Expected Output

<class 'pandas.core.series.Series'>
<class 'pandas.core.series.Series'>

output of pd.show_versions()

pandas: 0.18.0

Comment From: jreback

this was fixed by #12531 in forthcoming 0.18.1

Comment From: rsdenijs

Ahh, i did not see that issue. Thanks!