Pandas: `item` has been deprecated

前端 未结 5 1486
情书的邮戳
情书的邮戳 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:18

    The method item() is still useful if you want to assert that the Series has length exactly 1, and also get that single value at the same time. I recommend replacing:

    result = ser.item()
    

    with:

    result = ser.values.item()
    

    which should do what you want.

提交回复
热议问题