到目前为止,我在这里使用了这行代码:
max_total_gross = event_data["max_total_gross"].loc[event_data["event_id"] == event_id].item()
自从我更新了 Pandas 后,我收到了 future 警告:
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:12: FutureWarning:
item
has been deprecated and will be removed in a future version if sys.path[0] == '':
我尝试以这种方式修复它,但结果不一样:
event_data.loc[event_data.event_id == event_id, 'max_total_gross']
我期望一个整数。
最佳答案
您也可以只使用 .iloc[0] ,但请记住,如果您调用它的系列中至少没有一项,它将引发 IndexError
。
s = event_data.loc[event_data.event_id == event_id, 'max_total_gross']
s.iloc[0]
关于python - Pandas : `item` 已被弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57390363/