首页 > 解决方案 > 外推(和内插)Pandas DataFrame

问题描述

我有一个熊猫数据框如下

在此处输入图像描述

(年份索引是 int64,Total_Population_Final 是浮点数。)

我想创建一个线性插值(和外推),但使用 pd.interpolate() 我似乎只能在两年之间创建一个插值(不能及时向前和向后扩展)。

标签: pythonpandastime-seriesinterpolationextrapolation

解决方案


更新:我已经解决了这个问题(供任何有兴趣以备将来参考的人),使用:

pd.interpolate(method="spline", order=1, limit_direction="both")

推荐阅读