I have problem with scipy.interpolate.interp1d
df =
ang frc
-40 -15605.47
-30 -16051.253
-20 -10895.4
-10 -6205.733
0 -1730.65
10 2697.85
20 7217.59
30 12022.48
40 17298.647
import pandas as pd
from scipy.interpolate import interp1d
df = pd.read_csv('111.txt', sep='\t')
print(df)
interpi = interp1d(df['frc'], df['ang'], fill_value='extrapolate')
print(interpi(-17000))
It gives import pandas as pd from scipy.interpolate import interp1d
df = pd.read_csv('111.txt', sep='\t') print(df) interpi = interp1d(df['frc'], df['ang'], fill_value='extrapolate') print(interpi(-17000))
It gives -8.717 which is clearly wrong!
I rather it gives Error
can anyone help?
I think this depends on your definition of "wrong". To view this problem from the perspective of the interpolator (or rather extrapolator): If x_new = - 17000
, ie, outside of the range, the following points (blue in the picture below) are used to extrapolate: (-15605.47, -40)
and (-16051.253, -30)
. From those, the interpolator learns that a decrease in frc
leads to an increase in ang
. See the following picture. I clipped interpolation range for visibility.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.