How to calculate the mode of a NumPy array in the Python programming language. More details: https://statisticsglobe.com/mode-nump...
Python code of this video:
import numpy as np # Load NumPy library
from scipy import stats
my_array = np.array([[1, 5, 2, 2, 1, 6], # Create example array
[7, 2, 3, 1, 8, 6],
[1, 3, 4, 2, 7, 1],
[1, 3, 2, 2, 8, 5]])
print(my_array) # Print example array
[[1 5 2 2 1 6]
[7 2 3 1 8 6]
[1 3 4 2 7 1]
[1 3 2 2 8 5]]
print(stats.mode(my_array)[0]) # Get mode of array columns
[[1 3 2 2 8 6]]
print(stats.mode(my_array, axis = 1)[0]) # Get mode of array rows
[[1]
[1]
[1]
[2]]
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – R Programming Group for Discussions & Questions: / statisticsglobe
Facebook – Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – R Programming Group for Discussions & Questions: / 12555223
LinkedIn – Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Music by bensound.com
Watch video Get Mode of NumPy Array in Python (2 Examples) | SciPy Library | How to Calculate by Column & Row online without registration, duration hours minute second in high quality. This video was added by user Statistics Globe 04 July 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 291 once and liked it 6 people.