Hướng dẫn dùng scipy.stats mode python
Return an array of the modal (most common) value in the passed array. If there is more than one such value, only one is returned. The bin-count for the modal bins is also returned. Parametersaarray_liken-dimensional array of which to find mode(s). axisint or None, optionalAxis along which to operate. Default is 0. If None, compute over the whole array a. keepdimsbool, optionalIf
set to Warning Unlike other reduction functions (e.g. Defines how to handle when input contains nan. The following options are available (default is ‘propagate’): Returnsmodendarray Array of modal values. countndarrayArray of counts for each mode. Notes The mode of object arrays is calculated using
Deprecated since version 1.9.0: Support for non-numeric arrays has been deprecated as of SciPy 1.9.0 and will be removed in 1.11.0. pandas.DataFrame.mode can be used instead. The mode of arrays with other dtypes is calculated using Examples >>> a = np.array([[6, 8, 3, 0], ... [3, 2, 1, 7], ... [8, 1, 8, 4], ... [5, 3, 0, 5], ... [4, 7, 5, 9]]) >>> from scipy import stats >>> stats.mode(a, keepdims=True) ModeResult(mode=array([[3, 1, 0, 0]]), count=array([[1, 1, 1, 1]])) To get mode of whole array, specify >>> stats.mode(a, axis=None, keepdims=True) ModeResult(mode=array([3]), count=array([3])) >>> stats.mode(a, axis=None, keepdims=False) ModeResult(mode=3, count=3) |