pandas.core.groupby.SeriesGroupBy.min#

SeriesGroupBy.min(numeric_only=False, min_count=-1, engine=None, engine_kwargs=None)[源代码]#

计算组的最小值。

Parameters:
numeric_onlybool,默认 False

仅包括浮点数、整数、布尔列。

在 2.0.0 版本发生变更: numeric_only 不再接受 None

min_countint,默认为 -1

执行操作所需的有效值数量。如果存在少于 min_count 个非NA值,则结果为NA。

enginestr,默认为 None None
  • 'cython' : 通过 cython 的 C 扩展运行滚动 apply。

  • 'numba'通过 numba 的 JIT 编译代码运行滚动 apply。

    仅当 raw 设置为 True 时可用。

  • None : 默认为 'cython' 或全局设置的 compute.use_numba

engine_kwargsdict,默认为 None None
  • 对于 'cython' 引擎,没有可接受的 engine_kwargs

  • 对于 'numba' 引擎,该引擎可以接受 nopythonnogil

    parallel 字典键。值必须是 TrueFalse'numba' 引擎的默认 engine_kwargs{'nopython': True, 'nogil': False, 'parallel': False},它将应用于 funcapply 分组聚合。

Returns:
Series 或 DataFrame

计算的每个组内的最小值。

Examples

对于 SeriesGroupBy:

>>> lst = ['a', 'a', 'b', 'b']
>>> ser = pd.Series([1, 2, 3, 4], index=lst)
>>> ser
a    1
a    2
b    3
b    4
dtype: int64
>>> ser.groupby(level=0).min()
a    1
b    3
dtype: int64

对于 DataFrameGroupBy:

>>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["tiger", "leopard", "cheetah", "lion"])
>>> df
          a  b  c
  tiger   1  8  2
leopard   1  2  5
cheetah   2  5  8
   lion   2  6  9
>>> df.groupby("a").min()
    b  c
a
1   2  2
2   5  8