Python 错误不可散列类型:'list' with pandas iloc

时间:2020-12-30 03:44:48

标签: python pandas list if-statement

我仍在学习 Python。我正在尝试使用下面的 if 语句检查是否满足任何平均温度的峰值,但我收到 TypeError: unhashable type: 'list'。有人可以帮助澄清问题并纠正它吗?

谢谢!

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():

0 个答案:

没有答案