Pandas dataframe.loc method too slow
There are plenty of ways achieves this without loop, pivot
, pivot_table
, crosstab
, groupby count
pd.crosstab(df.user,df.document)
Out[1283]:
document article blogpost book
user
jane 1 3 2
jim 1 1 0
john 0 0 2