Skip to content

Commit

Permalink
Merge pull request #1884 from JanSchulz/cat_fixes
Browse files Browse the repository at this point in the history
BUG: Add compat code for pd.Categorical in pandas>=0.15
  • Loading branch information
josef-pkt committed Aug 14, 2014
2 parents 20c59d2 + 83be7a5 commit 53dccdd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion statsmodels/tools/grouputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ def labels(self):
if hasattr(self.index, 'labels'):
return self.index.labels
else: # pandas version issue here
return pd.Categorical(self.index).labels[None]
# Compat code for the labels -> codes change in pandas 0.15
# FIXME: use .codes directly when we don't want to support pandas < 0.15
tmp = pd.Categorical(self.index)
return getattr(tmp, "codes", tmp.labels)[None]


@property
def group_names(self):
Expand Down

0 comments on commit 53dccdd

Please sign in to comment.