I've recently upgraded Python to 3.7.6 and my existing code:
df['Simple_Avg_Return'] = df.groupby(['YF_Ticker'])['Share_Price_Delta_Percent', 'Dividend_Percent'].transform(
sum).divide(2).round(2)
Is now throwing this warning:
FutureWarning: Indexing with multiple keys (implicitly converted to a
tuple of keys) will be deprecated, use a list instead.
How would I go about converting this to a list as advised and where?
You need to use an extra bracket around ['Share_Price_Delta_Percent', 'Dividend_Percent']
Like this,
df['Simple_Avg_Return'] = df.groupby(['YF_Ticker'])[['Share_Price_Delta_Percent', 'Dividend_Percent']].transform(
sum).divide(2).round(2)
Quoting @ALollz comment
The decision was made https://github.com/pandas-dev/pandas/issues/23566. To keep compatibility between 0.25 and 1.0 they didn't remove the feature but added a warning in 1.0. Likely it will be removed in the next major deprecation cycle.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With