I have the following dataframe:
M P
2022-01-10 250
2022-04-03 100
2022-05-26 350
2022-08-01 200
... ...
^just an example. Basically I have some dates and some prices associated with them.
I'm trying to create a daily time-series curve using the above fixed points with the cubic splining method.
I've looked at using the following -
from scipy.interpolate import CubicSpline
cs = CubicSpline(df['M'], df['P'])
But I get the following error -
TypeError: float() argument must be a string or a number, not 'datetime.date'
because it doesn't like the date variable type. Two questions:
a) Basically, how do I interpolate the x, y to produce my curve?
b) Secondly, I'm using this method to try and replicate the 'S' curve in the following documentation chart:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html
...however what I'm not them sure of is how I construct a daily time series with dates / calculated prices which corresponds to this curve? Will that automatically happen when the CubicSpline method is called?
Any help would be greatly appreciated!
Create
DatetimeIndexbyDataFrame.set_index, add missing values for daily frequency byDataFrame.asfreqand last useDataFrame.interpolatewith methodcubicspline: