numpy.mean(arr, axis = None) : Compute the arithmetic mean (average) of the given data (array elements) along the specified axis.
arr : [array_like]input array.
axis : [int or tuples of int]axis along which we want to calculate the arithmetic mean. Otherwise, it will consider arr to be flattened(works on all
the axis). axis = 0 means along the column and axis = 1 means working along the row.
out : [ndarray, optional]Different array in which we want to place the result. The array must have the same dimensions as expected output.
dtype : [data-type, optional]Type we desire while computing mean.
Results : Arithmetic mean of the array (a scalar value if axis is none) or array with mean values along specified axis.
arr : [20, 2, 7, 1, 34] mean of arr : 12.8
mean of arr, axis = None : 18.6 mean of arr, axis = 0 : [17.33333333 8.33333333 31. 14. 22.33333333] mean of arr, axis = 1 : [24. 15. 16.8] out_arr : [0 1 2] mean of arr, axis = 1 : [24 15 16]
- Python | Merge Python key values to list
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Reading Python File-Like Objects from C | Python
- Python | Convert list to Python array
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to Python Libraries
- Python | Add Logging to a Python Script
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- gcd() in Python
- max() and min() in Python
- try-except vs If in Python
- pow() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.