pandas.core.resample.Resampler.mean#
- final Resampler.mean(numeric_only=False, *args, **kwargs)[源代码]#
计算组的平均值,排除缺失值。
- Parameters:
- numeric_onlybool,默认 False
仅包含 float, int 或 boolean 数据。
在 2.0.0 版本发生变更: numeric_only 现在默认为
False。
- Returns:
- DataFrame 或 Series
组内值的平均值。
Examples
>>> 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').mean() 2023-01-01 1.5 2023-02-01 3.5 Freq: MS, dtype: float64