pandas.core.resample.Resampler.asfreq#

final Resampler.asfreq(fill_value=None)[源代码]#

返回新频率下的值,本质上是重新索引。

Parameters:
fill_valuescalar, optional

用于缺失值的值,在升采样期间应用(请注意,这不会填充已存在的 NaN)。

Returns:
DataFrame 或 Series

指定频率下的值。

参见

Series.asfreq

将时间序列转换为指定频率。

DataFrame.asfreq

将时间序列转换为指定频率。

Examples

>>> 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