Home > database >  add rows in pandas with values from a linear regression based on other rows
add rows in pandas with values from a linear regression based on other rows

Time:04-08

I have a dataframe with two columns Date_of_journey and Price. The column Date_of_journey takes values between 1 and 119 but it has only 37 rows. So a lot of dates are missing.

Is there a simple way to add those dates where the price is somewhere in between the previous and next row?

Here is a plot of the data to give you an idea. I would like to add a row with Date_of_journey=4 and 5 with a Price that fits the gray curve. enter image description here

CodePudding user response:

You could resample your pd.DataFrame to a new range using RangeIndex() and interpolate between the known values using Plot based on 5 datapoints

  • Related