我有一个pandas数据帧df
,大约有1000行,但有500列。列名为Run1、Run2、…、Run500
现有索引是datetime
。在
dataframe的示例数据如下:
df.ix[1:4,1:4]
Run1 Run2 Date
2019-04-01 01:00:00 23.0263 23.0263 2019-04-01
2019-04-01 01:00:00 19.2212 19.2212 2019-04-01
2019-04-02 01:00:00 19.3694 19.3694 2019-04-02
2019-04-02 01:00:00 19.3694 19.3694 2019-04-02
我可以尝试以下方法:
^{2}$但我需要以下几点:
import pandas as pd
import numpy as np
pd.pivot_table(df, index=['Date'], values=['Run1', 'Run2', ...., 'Run500'], aggfunc=[np.mean])['mean']
我想这是
groupby
+mean
相关问题 更多 >
编程相关推荐