python - python中每15行数据框的平均值
问题描述
我有一个(1500x11)的数据框。我必须选择 15 行中的每一行并分别取每 11 列的平均值。所以我的最终数据框的尺寸应该是 100x11。如何在 Python 中做到这一点。
解决方案
The following should work:
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)
推荐阅读
- docker - 在 Docker 中连接到 neo4j 时出现 py2neo 地址错误
- java - 按钮应该通过字符串数组单击 5 次,停止 5 秒然后继续(单击 5 次)一致,错误
- reactjs - 无法在 CodeSandbox 的 create-react-app Temple 中从 css 切换到 scss
- node.js - git ref refs/heads/dashboard-angular 不存在或您没有权限
- php - PHP搜索MySQL数据库致命错误
- javascript - 在 MapQuest 中捕获标记拖动的纬度和经度
- google-analytics - 谷歌分析与 Power Bi 提取
- jquery - 如何使用javascript在html表中打印json数据
- php - mysqli_stmt_bind_param():无效的对象或资源 mysqli_stmt
- css - CSS:为什么这些响应式正方形不是完全正方形的?