Skip to content Skip to sidebar Skip to footer

Python Dataframe Resample List Data

I have a data frame and I am providing a plot to explain what I am looking for. My dataframe has lists as cells. Actual points are provided ones, resample data are the ones to be

Solution 1:

You can use pandas.DataFrame.interpolate:

df = pd.DataFrame({'Xact':[1.5,2.5,2.9,3.4,3.8,4.7,5.2,8.4,10.3],
                   'Yact':[10,20,30,40,50,60,70,40,20]})

df_new = pd.DataFrame({'Xact': [1,2,3,4,5,6,7,8,9,10]})

You can then combine the two dataframes and interpolate. There are several interpolation methods (see. scipy's documentation):

pd.concat([df, df_new]).set_index('Xact').sort_index().interpolate(method='index')

initial data:

initial

interpolated data (method="linear"):

interpolated

interpolated data (method="index"):

interpolated (index)

Post a Comment for "Python Dataframe Resample List Data"