我有一个 (1500x11) 的数据框。我必须选择 15 行中的每一行,并分别取每 11 列的平均值。所以我的最终数据框尺寸应为 100x11。如何在 Python 中执行此操作。
最佳答案
以下应该有效:
dfnew=df[:0]
for i in range(100):
df2=df.iloc[i*15:i*15+15, :]
x=pd.Series(dict(df2.mean()))
dfnew=dfnew.append(x, ignore_index=True)
print(dfnew)
关于python - python 中数据帧每 15 行的平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64059897/