import pandas as pd d = pd.DataFrame() d['date'] = ['2019-01-01', '2019-01-02', '2019-01-04', '2019-01-07', '2019-01-09', '2019-01-11'] d['val'] = [10, 20, 30, 40, 50, 30] d['date'] = pd.to_datetime(d['date']) helper = pd.DataFrame({'date': pd.date_range(d['date'].min(), d['date'].max())}) d = pd.merge(d, helper, on='date', how='outer').sort_values('date') d['val'] = d['val'].interpolate(method='linear') 插值选择方法不止有线性(linear),还可以是 nearest:最邻近插值法 zero:阶梯插值 slinear、linear:线性插值 quadratic、cubic:2、3阶B样条曲线插值(详情请参考官方文档)
Python Pandas
https://www.cnblogs.com/zhenyauntg/p/13188221.html