Pandas无法设置没有定义索引的帧和无法转换为序列的值

2024-10-03 06:30:11 发布

您现在位置:Python中文网/ 问答频道 /正文

df_players.loc[df_players['Player']=='Vitor Gabriel'][['Points']]

印刷品:

           Points
407           0.0
18805         0.0
19634         0.0
20459         7.2
21285         0.0
22111         0.0
22936         0.0

现在如果我这样做:

a1_points = df_players.loc[df_players['Player']=='Vitor Gabriel'][['Points']]
a1_points['RollingAvg'] = a1_points.rolling(window=4, center=False).mean()

我得到一个错误:

ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series

我错过了什么


Tags: falsedfa1windowlocpointscenterplayer