Q:

Write a NumPy program to calculate mean across dimension, in a 2D numpy array

0

Write a NumPy program to calculate mean across dimension, in a 2D numpy array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([[10, 30], [20, 60]])
print("Original array:")
print(x)
print("Mean of each column:")
print(x.mean(axis=0))
print("Mean of each row:")
print(x.mean(axis=1))

Sample Output:

Original array:                                                        
[[10 30]                                                               
 [20 60]]
Mean of each column:                              
[ 15.  45.]                                                            
Mean of each row:                                                   
[ 20.  40.]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now