pandas.core.resample.Resampler.sum #

最终 重采样器。sum ( numeric_only = False , min_count = 0 , * args , ** kwargs ) [来源] #

计算组值的总和。

参数
numeric_only布尔值,默认 False

仅包含 float、int、boolean 列。

版本 2.0.0 中更改: numeric_only 不再接受None.

min_count int,默认0

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

返回
系列或数据框

计算每组内的值的总和。

例子

>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').sum()
2023-01-01    3
2023-02-01    7
Freq: MS, dtype: int64