Code :-
client.datapoints.insert_dataframe(df, dropna=True)
Error:-
DataFrame index must be `pd.DatetimeIndex`, got: <class 'pandas.core.indexes.base.Index'>
Code :-
client.datapoints.insert_dataframe(df, dropna=True)
Error:-
DataFrame index must be `pd.DatetimeIndex`, got: <class 'pandas.core.indexes.base.Index'>
Best answer by Stig Harald Gustavsen
You need to have a datetime index on your data frame.
#check it has the dtype=datetiem64[ns]
df.index
If the datetime is not the index then you can set the ‘datetime_indexed_series’ by setting the series with dtype=datetime64[ns] as the index:
df = df.set_index('your_datetime_series_name')
then check that your index has now datetime64[ns] dtype.
If none of your series have the datetime64[ns] dtype, but you have a string or an int representing the timestamp of the dataframe rows. then convert the string or the int into a datetime64[ns], check out this link https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html
If it is a unix epoc time in ms (milliseconds since 1/1-1970) then you can convert that to a datetime series:
#if the series is in integers on unix epoc format, you can use some numpy inherited functionality and convert the dtype there
#if it is integer values unix epoc in ms
df['timestamp'] = df['unix_epoc_ms_series'].view('datetime64[ms]')
df.set_index('timestamp')
#or just set the index directly:
df.set_index(df['unix_epoc_ms_series'].view('datetime64[ms]')
#you can also change the ms in datetime64[ms] to ns or s on the integer format of the unixtimestamp if they are nanoseconds or seconds.
Then after you have a datetime index, try to insert the data points from the dataframe again. anyhow, this is things a good pandas user should manage nicely. hope this helps :)
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.