I have several dataframes where I need to reduce the dataframe to a time span for all of them. So that I don't have to reduce the codeblock over and over again, I would like to write a function.
Currently everything is realized without working by the following code:
timerange = (df_a['Date'].max() - pd.DateOffset(months=11))
df_a_12m = df_a.loc[df_a['Date'] >= timerange]
my approach:
def Time_range(Data_1, x,name, column, name):
t = Data_1[column].max() - pd.DateOffset(months=x)
'df'_ + name = Data_1.loc[Data_1[column] >= t]
unfortunately this does not work