Closed
Description
Description
I have a dataframe with a Datetime index, and pandas 0.23.4 causes a Kernel died, restarting notification when using DF.rolling with a specified window as a string (i.e. '2D'). This worked in previous versions of pandas (at least 0.21 and 0.20). Any advice on this bug/issue would be great!
Code example
from datetime import datetime,timedelta
import pandas as pd, numpy as np
date_today = datetime.now()
days = pd.date_range(date_today, date_today + timedelta(365), freq='D')
np.random.seed(seed=421)
data = np.random.randint(1, high=100, size=len(days))
df = pd.DataFrame({'DateCol': days, 'metric': data})
TIME_WINDOW='21D'
#Minimum amount of values
MIN_VALUES=2
#Set the index of the DF as a DateTime
df.set_index('DateCol',inplace=True)
test=df.rolling(window=TIME_WINDOW,min_periods=MIN_VALUES,closed='left')['metric'].agg('max')
Result:
Kernel died, restarting
Pandas 0.23.4 documentation
The pandas 0.23.4 documentation shows the window can be a string:
df.rolling('2s').sum()