pandas.core.resample.Resampler.transform#
- final Resampler.transform(arg, *args, **kwargs)[源代码]#
对每个组调用生成类似索引的 Series 的函数。
返回具有转换值的 Series。
- Parameters:
- argfunction
应用于每个组。应返回具有相同索引的 Series。
- Returns:
- Series
Examples
>>> s = pd.Series([1, 2], ... index=pd.date_range('20180101', ... periods=2, ... freq='1h')) >>> s 2018-01-01 00:00:00 1 2018-01-01 01:00:00 2 Freq: h, dtype: int64
>>> resampled = s.resample('15min') >>> resampled.transform(lambda x: (x - x.mean()) / x.std()) 2018-01-01 00:00:00 NaN 2018-01-01 01:00:00 NaN Freq: h, dtype: float64