So in case you want all means for a specific column, say ‘b’, you can just use groupby and aggregate by mean
. For example:
mean_df = df2.groupby("b").mean()
Output:
a c
b
2 4 4
5 4 6
CLICK HERE to find out more related problems solutions.