mardi 29 décembre 2020

Python error unhashable type: 'list' with pandas iloc

I am still learning Python. I am trying to check if the peak value of any of the average temperatures is satisfied using the if statement below but I am getting TypeError: unhashable type: 'list'. Can someone help clarify the issue and correct it?

Thank you!

df['T1avg'] = df['T1'].rolling(11, center=True).mean().shift(50)
df['T2avg'] = df['T2'].rolling(11, center=True).mean().shift(50)
averages = ['T1avg','T2avg']

pctl = np.nanpercentile(df, 1, axis=0)  # calculation of 1% percentile
peak = df.iloc[-1] < pctl

for i in range(1, len(df)):
if (peak.loc(axis=0)[i, averages]).any():

Aucun commentaire:

Enregistrer un commentaire