- Code: Select all
`import numpy as np`

import pandas as pd

a = pd.DataFrame(np.random.rand(5,5),columns=list('ABCDE'))

b = a.mean(axis=0)

>>> b

A 0.536495

B 0.522431

C 0.582918

D 0.600779

E 0.371422

dtype: float64

My application is to take the averaged values and insert them into another dataframe, e.g.

- Code: Select all
`# Average parameters collected when "hour of day" (data.hod) is 13`

tmp = pd.DataFrame()

tmp = pd.concat( [tmp,data[data.hod==13].mean(axis=0)], axis=0)

This is where it gets ticked off and gives the AttributeError: 'Series' object has no attribute '_data'

I would expect there exists some way of averaging a dataframe that does not involve converting the output to a Series. I know this is doable when the dataframe is multi-indexed, but that is not done here. Does anyone know how to perform this operation?