pandas.core.resample.Resampler.asfreq #
- 最终 重采样器。asfreq ( fill_value = None ) [来源] #
返回新频率的值,本质上是重新索引。
- 参数:
- fill_value标量,可选
用于缺失值的值,在上采样期间应用(请注意,这不会填充已经存在的 NaN)。
- 返回:
- 数据框或系列
指定频率下的值
也可以看看
Series.asfreq
将 TimeSeries 转换为指定频率。
DataFrame.asfreq
将 TimeSeries 转换为指定频率。
例子
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex( ... ['2023-01-01', '2023-01-31', '2023-02-01', '2023-02-28'])) >>> ser 2023-01-01 1 2023-01-31 2 2023-02-01 3 2023-02-28 4 dtype: int64 >>> ser.resample('MS').asfreq() 2023-01-01 1 2023-02-01 3 Freq: MS, dtype: int64