Skip to content

Commit

Permalink
Update pandas astype Categorical to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
kahnvex committed May 9, 2018
1 parent c1e28e1 commit f5bd480
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hidi/matrix.py
Expand Up @@ -4,6 +4,7 @@

from hidi.transform import Transform
from hidi.linalg import dot
from pandas.api.types import CategoricalDtype
from pyvalid import accepts
from scipy.sparse import csr_matrix
from sklearn.model_selection import train_test_split, KFold, StratifiedKFold
Expand Down Expand Up @@ -142,8 +143,8 @@ def transform(self, df, **kwargs):
item_u = list(df.item_id.unique())
data = df.score.as_matrix()

row = df.link_id.astype('category', categories=link_u).cat.codes
col = df.item_id.astype('category', categories=item_u).cat.codes
row = df.link_id.astype(CategoricalDtype(categories=link_u)).cat.codes
col = df.item_id.astype(CategoricalDtype(categories=item_u)).cat.codes

outshape = (len(link_u), len(item_u))
in_tuple = (data, (row, col))
Expand Down

0 comments on commit f5bd480

Please sign in to comment.