Skip to content

Instantly share code, notes, and snippets.

@idling-mind
Created August 20, 2017 16:18
Show Gist options
  • Save idling-mind/2b1e6cf4e3dc6f0e2b943e5c34dab881 to your computer and use it in GitHub Desktop.
Save idling-mind/2b1e6cf4e3dc6f0e2b943e5c34dab881 to your computer and use it in GitHub Desktop.
Interpolation for a single point for x-y data from pandas dataframe
import pandas as pd
import numpy as np
mydata = pd.DataFrame({
"Temp":[10,20,30,40,50],
"Data":[123,323,335,567,886]
})
point_to_interpolate = 33
interpolated_data = np.interp(x=point_to_interpolate, xp=mydata.Temp, fp=mydata.Data)
# Returns 404.6 which is same as (567-335)/10*3+335
@idling-mind
Copy link
Author

bokeh_plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment