This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / stats / _mstats_basic / mode

function

scipy.stats._mstats_basic:mode

source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_mstats_basic.py:314

Signature

def mode(a, axis = 0)

Summary

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

Parameters

a : array_like

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

axis : int or None, optional

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

Returns

mode : ndarray

Array of modal values.

count : ndarray

Array of counts for each mode.

Notes

For more details, see scipy.stats.mode.

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.]))

Aliases

  • scipy.stats._mstats_basic.mode