I want to get the yearly mean of a list of values associated with a zip code the problem I get this error code, can you please help me out.
My code is:
np.random.seed(2020)
rng = pd.date_range('2/9/2017', '3/19/2019', freq='10T')
df2 = pd.DataFrame({'SCORE':np.random.randint(1000, size=len(rng))}, index=rng)
out = pd.Series({x: df2.loc({x: df2.loc[f'02/9/{x}', :f'03/19/{x+1}', 'SCORE'].mean()
for x in range(df2.index.year.min(), df2.index.year.max()+1)})
The error is:
File "<ipython-input-150-61dcc574e6e3>", line 1
out = pd.Series({x: df2.loc({x: df2.loc[f'02/9/{x}', :f'03/19/{x+1}', 'SCORE'].mean()
^
SyntaxError: invalid syntax