Pandas: `item` has been deprecated

前端 未结 5 1487
情书的邮戳
情书的邮戳 2020-12-17 14:50

So far I used this line of code here:

max_total_gross = event_data[\"max_total_gross\"].loc[event_data[\"event_id\"] == event_id].item()

Si

5条回答
  •  眼角桃花
    2020-12-17 15:19

    You could also just use .iloc[0], but keep in mind that it will raise an IndexError if there is not at least one item in the series you're calling it on.

    s = event_data.loc[event_data.event_id == event_id, 'max_total_gross']
    s.iloc[0]
    

提交回复
热议问题