Question

Consider we have two dataframes:

a = DataFrame([[1,1],[2,2]])
b = DataFrame([[1,1],[10,10]])

How do we take the mean of two dataframes so that we get:

   0  1 
0  1  1
1  6  6

Also how can we get standard deviation. Thanks in advance!

Was it helpful?

Solution

you can add the two DataFrames together to get a new one:

(a+b)/2

Output:

     0   1
0    1   1
1    6   6

[2 rows × 2 columns]

Or if you wanted to do some more complicate processing on the result:

c = a+b
c.std()

output:

0    7.071068
1    7.071068

OTHER TIPS

You can simply add them up, then divide by 2:

(a + b) / 2

Output:

   0  1
0  1  1
1  6  6

[2 rows x 2 columns]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top