Pandas: `item` has been deprecated
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.
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]