I would like to add a new column between each of the date columns, with the interpolated value using the previous and next value to get a month value.
data = [['Jane', 10,11,45,66,21], ['John',11,55,34,44,22],['Tom',23,43,12,11,44]]
df = pd.DataFrame(data, columns = ['Name', '09-Aug', '02-Sep','18-Oct','02-Nov','14-Dec'])
This returns the following:
In between each column after the first one, I would like to add one which contains the month preceding it, and the interpolated value based on the preceding and next column.
So eg:
I tried to first add a column between each one using the following code:
N = len(df.columns) #
for i in range(0,N): #
df.insert(i,'','',allow_duplicates=True)
But this only adds columns to the left of the table, not between each one. Once I had added the columns, I was thinking of writing a function to perform the linear interpolation.
Does anyone have a suggestion on the correct way around to tackle this?