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
Auf dieser Seite können Sie das Online-Video Get Mode of NumPy Array in Python (2 Examples) | SciPy Library | How to Calculate by Column & Row mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Statistics Globe 04 Juli 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 291 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!