Reputation: 4807
I have a pandas dataframe df
with about 1000 rows but 500 columns. The columns are named Run1, Run2, ..., Run500
The existing index is datetime
.
Sample data from dataframe is as follows:
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
I can do the trying the following:
pd.pivot_table(df, index=['Date'], values=['Run1'], aggfunc=[np.mean])['mean']
But I need to the following:
import pandas as pd
import numpy as np
pd.pivot_table(df, index=['Date'], values=['Run1', 'Run2', ...., 'Run500'], aggfunc=[np.mean])['mean']
Upvotes: 0
Views: 832