两个数据点之间的线性插值 [英] linear interpolation between two data points
本文介绍了两个数据点之间的线性插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个数据点 x
和 y
:
x = 5 (value corresponding to 95%)
y = 17 (value corresponding to 102.5%)
否我想计算 xi
的值,该值应该对应于100%。
No I would like to calculate the value for xi
which should correspond to 100%.
x = 5 (value corresponding to 95%)
xi = ?? (value corresponding to 100%)
y = 17 (value corresponding to 102.5%)
我应该使用python吗?
How should I do this using python?
推荐答案
是你想要的?
In [145]: s = pd.Series([5, np.nan, 17], index=[95, 100, 102.5])
In [146]: s
Out[146]:
95.0 5.0
100.0 NaN
102.5 17.0
dtype: float64
In [147]: s.interpolate(method='index')
Out[147]:
95.0 5.0
100.0 13.0
102.5 17.0
dtype: float64
这篇关于两个数据点之间的线性插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文