简体   繁体   English

从 dataframe 获取近似值

[英]Get approx value from dataframe

I'd like to get the "Distance" value for a given "LapTimeSeconds" that isn't present in the table, is there any way to do that?我想获得表中不存在的给定“LapTimeSeconds”的“距离”值,有什么办法吗?

Maybe using interpolation?也许使用插值? But how?但是怎么办? Thanks in advance提前致谢

# Something like this?
driver1_tel.loc[(driver1_tel["LapTimeSeconds"] == (3.0)]

数据框

You could just use scipy's interpolate function on the columns of interest.您可以在感兴趣的列上使用 scipy 的插值 function。 From looking at what you have written it would go something like:通过查看您所写的内容,它会 go 类似于:

from scipy import interpolate
x = df.LaptimeSecond
y = df.Distance
f = interpolate.interp1d(x, y)
ynew = f(3)

The variable ynew would give you the interpolated distance for a laptime of 3 seconds.变量 ynew 将为您提供 3 秒单圈时间的插值距离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM