-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Description
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
Metadata
Metadata
Assignees
Labels
BugCategoricalCategorical Data TypeCategorical Data TypeDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves