scipy.stats.mstats.

mode#

scipy.stats.mstats.mode(a, axis=0)[source]#

Returns an array of the modal (most common) value in the passed array.

Deprecated since version 2.0.0: scipy.stats.mstats.mode is deprecated as of SciPy 2.0.0 and will be removed, along with the scipy.stats.mstats namespace, in SciPy 2.4.0. For similar functionality, use scipy.stats.mode with MArray(s) instead of NumPy masked array(s).

Parameters:
aarray_like

n-dimensional array of which to find mode(s).

axisint or None, optional

Axis along which to operate. Default is 0. If None, compute over the whole array a.

Returns:
modendarray

Array of modal values.

countndarray

Array of counts for each mode.

Notes

For more details, see scipy.stats.mode.

Array API Standard Support

mode is not in-scope for support of Python Array API Standard compatible backends other than NumPy.

See Support for the array API standard for more information.

Examples

>>> import numpy as np
>>> from scipy import stats
>>> from scipy.stats import mstats
>>> m_arr = np.ma.array([1, 1, 0, 0, 0, 0], mask=[0, 0, 1, 1, 1, 0])
>>> mstats.mode(m_arr)  # note that most zeros are masked
ModeResult(mode=array([1.]), count=array([2.]))