Check scipy.stats.mode() (inspired by @tom10's comment):

import numpy as np
from scipy import stats

a = np.array([[1, 3, 4, 2, 2, 7],
              [5, 2, 2, 1, 4, 1],
              [3, 3, 2, 2, 1, 1]])

m = stats.mode(a)
print(m)

Output:

ModeResult(mode=array([[1, 3, 2, 2, 1, 1]]), count=array([[1, 2, 2, 2, 1, 2]]))

As you can see, it returns both the mode as well as the counts. You can select the modes directly via m[0]:

print(m[0])

Output:

[[1 3 2 2 1 1]]
Answer from fgb on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-calculate-the-mode-of-numpy-array
How to Calculate the Mode of NumPy Array? - GeeksforGeeks
July 23, 2025 - scipy.stats.mode function is designed specifically to find the mode of an array or dataset. It handles edge cases and is optimized for performance. This method returns not just the mode but also the count of its occurrences.
🌐
Delft Stack
delftstack.com › home › howto › numpy › python numpy mode
How to Calculate the Mode of Array in NumPy | Delft Stack
February 2, 2024 - As you can see in the first two lines, the statistics module and numpy are imported with the aliases statistics and np, respectively. The NumPy array, named data, is then defined, containing a set of numerical values. Subsequently, the statistics.mode() function is applied to the data array, calculating the mode of the dataset.
🌐
CodeSignal
codesignal.com › learn › courses › numpy-basics › lessons › basic-statistical-operations-in-numpy
Basic Statistical Operations in NumPy
The mode is the most frequent value in your data set, which can be calculated using the mode() function from scipy's stats module. ... import numpy as np from scipy import stats grades = np.array([85, 87, 89, 82, 86, 80, 92, 80]) print("Mean:", np.mean(grades)) # Mean: 85.125 print("Median:", ...
🌐
Moonbooks
en.moonbooks.org › Articles › How-to-find-the-most-frequent-value-or-mode-in-a-numpy-array-
How to find the most frequent value or mode in a numpy array ?
December 6, 2023 - Python offers several approaches to determine the mode, providing flexibility and versatility in finding the most frequently occurring value: First, let's generate a simulated 2D array filled with random integer · import numpy as np data = np.random.randint(0,4,(4,5)) print(data)
🌐
Learning About Electronics
learningaboutelectronics.com › Articles › How-to-compute-the-mean-median-and-mode-in-Python.php
How to Compute the Mean, Median, and Mode in Python
This means that we reference the numpy module with the keyword, np. We also have to import stats from the scipy module, since we need this in order to get the mode (numpy doesn't supply the mode).
Find elsewhere
🌐
Statology
statology.org › home › how to calculate mean, median, and mode with numpy
How to Calculate Mean, Median, and Mode with NumPy
June 4, 2024 - Particularly applicable to categorical data, the mode reminds us of the most popular category. There is no direct NumPy mode function, but there are numerous other Python modules that are available to calculate the mode directly, including the Python statistics module and Scipy’s stats module.
🌐
Educative
educative.io › answers › how-to-compute-mean-median-and-mode-using-numpy-in-python
How to compute mean, median, and mode using NumPy in Python
The mode is used in applications where identifying the most frequent event is crucial: Finding the most popular product or service. Identifying the most common customer purchase. Identifying the most common grade or score range. NumPy does not have a built-in mode function, but we can use SciPy to compute the mode...
🌐
Mode
mode.com › python-tutorial › libraries › numpy
NumPy | Python Library - Mode
May 23, 2016 - ThoughtSpot acquires Mode to define the next generation of collaborative BI >>Learn More ... Learn Python for business analysis using real-world data. No coding experience necessary. ... NumPy is a scientific computing library for Python.
🌐
NumPy
numpy.org › doc › stable › reference › routines.statistics.html
Statistics — NumPy v2.5 Manual
ptp(a[, axis, out, keepdims]) · Range of values (maximum - minimum) along an axis
🌐
The Coding Forums
thecodingforums.com › programming languages › python
Is there a way to get a single mode using all the points within a 2D array? | Python | Coding Forums
October 18, 2022 - a = np.array(arrOriginalImage01[YPixelsPerStud*(Yi01-1):YPixelsPerStud*Yi01,XPixelsPerStud*(Xi01-1):XPixelsPerStud*Xi01,0]) arrPixelPerStud02[Yi01-1,Xi01-1,0] = np.average(stats.mode(np.reshape(a,YPixelsPerStud*XPixelsPerStud))[0],None) I think I found a solution by using "numpy.Reshape" I think the numpy.average part of the code is superfluous but i put it in incase there are multiple modes.
🌐
GitHub
github.com › numpy › numpy › issues › 8499
Mode function for ndarray · Issue #8499 · numpy/numpy
January 19, 2017 - I was wondering if there was any particular reason as to why there doesn't exist a mode function like the mean and median functions that work on ndarray. I feel that it should be provided. ( On tha...
Author: numpy
🌐
NumPy
numpy.org › doc › 2.1 › reference › routines.statistics.html
Statistics — NumPy v2.1 Manual
ptp(a[, axis, out, keepdims]) · Range of values (maximum - minimum) along an axis
🌐
Medium
medium.com › @ishitaguharoy › five-statistics-functions-in-numpy-b61d9fa2f379
Mean, Median, Mode with NumPy | Medium
March 11, 2022 - The five most used measures- mean, median, range, standard deviation, and variance, in statistics, have been discussed along with their potential uses. NumPy has other functions for statistics such as covariance, correlation coefficient, quantiles, percentiles, etc.
🌐
Kaggle
kaggle.com › getting-started › 419794
Beginner Tip: How to Call Mode? Not np.mode() | Kaggle
Sometimes, you may need to find ... beginners may be left wondering why np.mode() doesn't work? The answer is numpy does not provide a method for mode....