Skip to content

Commit

Permalink
make load work with newer pandas (fix #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Jun 17, 2020
1 parent 7473693 commit e8289b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ def load(filepath):
tracks[column] = pd.to_datetime(tracks[column])

SUBSETS = ('small', 'medium', 'large')
tracks['set', 'subset'] = tracks['set', 'subset'].astype(
'category', categories=SUBSETS, ordered=True)
try:
tracks['set', 'subset'] = tracks['set', 'subset'].astype(
'category', categories=SUBSETS, ordered=True)
except ValueError:
# the categories and ordered arguments were removed in pandas 0.25
tracks['set', 'subset'] = tracks['set', 'subset'].astype(
pd.CategoricalDtype(categories=SUBSETS, ordered=True))

COLUMNS = [('track', 'genre_top'), ('track', 'license'),
('album', 'type'), ('album', 'information'),
Expand Down

0 comments on commit e8289b9

Please sign in to comment.