我需要对一个数据框进行重新采样,不同的列使用不同的函数。
import pandas as pd
import numpy as np
df=pd.DataFrame(index=pd.DatetimeIndex(start='2020-01-01 00:00:00', end='2020-01-02 00:00:00', freq='3H'),
data=np.random.rand(9,3),
columns=['A','B','C'])
df = df.resample('1H').agg({'A': 'ffill',
'B': 'interpolate',
'C': 'max'})
像'mean'、'max'、'sum'这样的函数可以正常使用。
但似乎无法像那样使用'interpolate'。
有什么解决方法吗?