Lets say I have the following dataframe, with continuous data at fixed intervals (so am not sure the tslearn KMeans clustering package is useful for this)
date value
2022-09-06 01:40:50.999059 0.2732
2022-09-05 19:55:02.242936 0.9771
.
.
.
I am trying to use the K means algorithm to cluster this but cannot use
df.date = pd.to_datetime(df.date)
data = df[["date","value"]]
model = KMeans(init="random",n_clusters=k,n_init=10,max_iter=300,random_state=4)
model.fit(data)
because I think the KMeans algorithm requires a float. How would I be able to use date as a feature in the KMeans algorithm?
Error:
TypeError: The DType <class 'numpy.dtype[datetime64]'> could not be promoted by <class 'numpy.dtype[float64]'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (<class 'numpy.dtype[datetime64]'>, <class 'numpy.dtype[float64]'>)