I am trying to make a function to calculate rolling mean or sum :
def rolling_lag_creator(dataset,i,func):
dataset['Bid']=dataset.loc[:,'Bid'].rolling(window=i).func()
return dataset
but this function is throwing error when i am calling this:
rolling_lag_creator(Hypothesis_ADS,5,mean)
Error:
NameError: name 'mean' is not defined
while below code works fine:
dataset['Bid']=dataset.loc[:,'Bid'].rolling(window=5).mean()
Can anyone help me how to call such methods as parameters, thank you.