EPL Machine Learning Project

I seem to be struggling with the following error while working through the ELP project and the video. I have played around with removing the “closed=‘left’” parameter, but that skews all of the data 1 week. Any input would be greatly appreciated.

def rolling_averages(group, cols, new_cols):
group = group.sort_values(“date”)
rolling_stats = group[cols].rolling(3, closed=‘left’).mean()
group[new_cols] = rolling_stats
group = group.dropna(subset=new_cols)
return group

ValueError: closed only implemented for datetimelike and offset based windows

Portfolio Project_ Predicting EPL Football Match Winners With Machine Learning.tar (373.5 KB)
Basics.ipynb (117.6 KB)

Click here to view the jupyter notebook file in a new tab

1 Like

Hi @pjo1005

I tried your code as-is. It worked for me.

The parameter has been changed in pandas version 1.2.0. Mine at the present is 1.3.0. If your version is the same then perhaps some other issue lingers here.

Check out the attached Jupyter Notebook. I have tested out all the options available for the ‘closed’ parameter.

does this stack overflow post sheds some ideas?
Basics_Updated.ipynb (127.1 KB)

Click here to view the jupyter notebook file in a new tab

2 Likes

Thank for the input. It appears that was the issue!

1 Like