>>> import numpy as np >>> data = np.array([[1, 2, 3], [5, 6, 7]]) >>> np.average(data, axis=0) array([ 3., 4., 5.])
Here is what the above code is Doing:
1. We import the numpy module as np.
2. We create a 2-dimensional array called data.
3. We call the average() function on data, and pass in axis=0 as an argument.
4. The average() function returns a 1-dimensional array containing the average of each column.