Reputation: 299
I pretty much copied the code here to convert my daily stock data to weekly data. It's saying that the how args in .resample() is now deprecated. I assume it wants me to do something like .max()
and .min()
or something. Is there a neat way to do that so that I don't get the message every time?
If it helps my DataFrame is:
Open High Low Close Adj Close Volume
Date
2017-10-23 4.99 5.04 4.94 4.94 4.94 13412313
2017-10-24 4.95 5.02 4.95 5.00 5.00 8655448
2017-10-25 5.02 5.05 5.00 5.05 5.05 13721794
2017-10-26 4.98 5.00 4.82 4.87 4.87 26708894
2017-10-27 4.88 4.91 4.77 4.79 4.79 25369776
2017-10-30 4.85 4.85 4.72 4.74 4.74 13791695
2017-10-31 4.73 4.73 4.64 4.64 4.64 20530300
2017-11-01 4.76 4.79 4.67 4.68 4.68 18949283
2017-11-02 4.76 4.92 4.76 4.87 4.87 18523514
2017-11-03 4.88 4.90 4.76 4.80 4.80 13961895
2017-11-06 4.83 4.86 4.80 4.80 4.80 10856694
2017-11-07 4.92 5.06 4.91 5.03 5.03 24469556
2017-11-08 4.96 4.98 4.88 4.90 4.90 19049326
2017-11-09 4.96 4.96 4.88 4.88 4.88 12104442
2017-11-10 4.90 4.91 4.82 4.86 4.86 12412000
Upvotes: 2
Views: 5327
Reputation: 30605
Use agg
instead of how
inside resample (edit in the code link suggested) i.e
output = df.resample('W').agg({'Open': take_first,
'High': 'max',
'Low': 'min',
'Close': take_last,
'Volume': 'sum'},
loffset = pd.offsets.timedelta(days=-6))
Open High Low Close Volume Date 2010-01-10 38.660000 40.700001 38.509998 40.290001 5925600 2010-01-17 40.209999 40.970001 39.279999 40.450001 6234600
The warning says that :
FutureWarning: how in .resample() is deprecated the new syntax is .resample(...)..apply()
So instead of apply
here we can use aggregate agg
for passing a dict of functions.
Upvotes: 4