How could i calculate a rolling average with f-stringed columns? Normally it's:
df.columns=['x','y']
rollingaverage = df.y.rolling(window=6).mean()
How do I do implement this given I use f-string? This didn't work:
concatted apple_y banana_y date apple banana
apple_bana 0.500 2 2010-02-20 True True
apple 0.400 3 2010-02-10 True False
banana 0.530 4 2010-01-12 False True
...
fruits= ['apple', 'banana']
for fruit in fruits:
selected_rows = df[ df[ fruit ] == True ]
df[f'{fruit}_rollingaverage'] = selected_rows.[f'{fruit}_y'].rolling(window=6).mean()