I am counting the number of ratings per user in my book reviews dataframe, by using:
df_new['ratings_per_user']=df_new.groupby('userID')['userID'].transform('count')
this seems to work, but it throws an error (or rather, a warning):
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
"""Entry point for launching an IPython kernel.
I don't understand how I can rewrite the above command using .iloc
, and, more generally, what the actual problem is.