我正在使用以下方法计算我的书评数据框中每个用户的评分数量:
df_new['ratings_per_user']=df_new.groupby('userID')['userID'].transform('count')
这似乎可行,但会引发错误(或更确切地说是警告):
/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.
我不知道如何使用.iloc
重写上面的命令,更一般的是,实际问题是什么。