I have a dataframe df as follows:
A B C
1 2 3
2 1 2
3 3 1
And I would like the mean of every column and make a dataframe with it. That would be in this example:
A B C
2 2 2
The code I did was:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10, 3), columns=list('ABC')) # To create df
dfs = np.array_split(df.sample(frac=1),4) # Split it in 4
daf = []
for i in range(len(dfs):
daf.append(dfs[i].mean())
daf.to_frame()
However I am unable to make it work.