I have a dataframe of the format below. I need to smooth the value column using univariate splines. For the purpose I am trying to use the scipy interpolate univariate spline function. I converted the datetime column of the dataframe below to datetime64 type.
When I try to feed it to the splines function however as x along with the value column as y I am getting the following error: UFuncTypeError: Cannot cast ufunc 'greater_equal' input 1 from dtype(float64) to dtype(<m8[ns]) with casting rule 'same_kind'. I can understand that the issue comes from the fact that my x column is a datetime object but I am not sure how to resolve it given that my data is time series data.
import pandas as pd
from scipy.interpolate import UnivariateSpline
d = {'datetime': ['08/07/2022 00:02:03.000','08/07/2022 00:15:06.050','08/07/2022 00:30:06.369','08/07/2022 00:31:03.025','08/07/2022 00:35:08.369','08/07/2022 00:37:59.258','08/07/2022 00:45:06.258','08/07/2022 00:45:25.025','08/07/2022 00:49:15.326','08/07/2022 00:51:45.058','08/07/2022 00:33:09.258'], 'value': [10,10.5,10.3,10.8,10.5,10.6,10.9,10.33,10.35,10.36,10.37]}
df = pd.DataFrame(data=d)
df['datetime']=pd.to_datetime(df['datetime'])
x=df['datetime']
y=df['value']
spl=UnivariateSpline(x,y)