Fielding是一个DataFrame,但是我不确定为什么会出现此错误:
ValueError:系列的真值不明确。使用a.empty,a.bool(),a.item(),a.any()或a.all()
RAR = []
for i in range(0,len(Fielding)):
position = (Fielding['POS'][i])
value = 0
if position == 'C':
value = (9.0/150.0) * (Fielding['GS'][i])
elif position == 'SS':
value = (7.0/150.0) * (Fielding['GS'][i])
elif position == '2B':
value = (3.0/150.0) * (Fielding['GS'][i])
elif position == '3B':
value = (2.0/150.0) * (Fielding['GS'][i])
elif position == '1B':
value = (-9.5/150.0) * (Fielding['GS'][i])
else:
value = 0
RAR.append(value)
这是我的DataFrame的示例。
yearID teamID playerID POS G GS
yearID teamID
1994 FLO 1994 FLO abbotku01 SS 99 93.0
OAK 1994 OAK aldremi01 1B 27 20.0
OAK 1994 OAK aldremi01 OF 35 18.0
SLN 1994 SLN alicelu01 2B 53 48.0
SLN 1994 SLN alicelu01 OF 2 0.0
TOR 1994 TOR alomaro01 2B 106 102.0
CLE 1994 CLE alomasa02 C 78 78.0
MON 1994 MON aloumo01 OF 106 106.0
SEA 1994 SEA amarari01 1B 2 0.0
SEA 1994 SEA amarari01 2B 42 37.0
SEA 1994 SEA amarari01 OF 16 7.0
SEA 1994 SEA amarari01 SS 7 5.0
CLE 1994 CLE amaroru02 OF 12 0.0
BAL 1994 BAL anderbr01 OF 109 109.0
CAL 1994 CAL anderga01 OF 4 3.0
SEA 1994 SEA anthoer01 OF 71 65.0
FLO 1994 FLO ariasal01 3B 15 4.0
FLO 1994 FLO ariasal01 SS 20 18.0
LAN 1994 LAN ashlebi01 OF 2 2.0
SDN 1994 SDN ausmubr01 1B 1 0.0
SDN 1994 SDN ausmubr01 C 99 94.0
任何帮助将不胜感激!