-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing precision for to_datetime in DataFrame serializer #328
Comments
Hi @Elfoniok, thanks for using our client.
You can change your index via: Can you share how your DataFrame looks like? Regards |
Yes I know I can use set_index. Maybe I was not clear since you are quoting me but somehow missing the point. In the link, I have pasted above, is a code branch for PeriodIndex. I don't know how it is used I am not very familiar with pandas. I am using dumb "int" like index or pandas Date. And yes I am using set_index on the chosen column. Anyway here is an example, and an attached data file.
|
You have to change your index to result of df.set_index('Date', inplace=True)
df.index = pandas.to_datetime(df.index, unit='s')
Thanks for clarification, I will fix it ASAP, meanwhile you can used the above workaround ⬆️ . |
Awesome, thanks for adding the docs as well, I really appreciate that! |
Steps to reproduce:
Maybe I am doing something wrong but importing Pandas Data Frames with this API is poorly documented, especially when it comes to pre-existing date columns, which is very common scenario if you need to import Data Frames.
I have failed to find any docs how date should be specified (column name? data type?) in Data Frame. So after consulting code I have found that it actually has to be an index!
https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/write/dataframe_serializer.py#L96
Well ok so be it. However I am not very familiar with PeriodIndex, is that common for Time Series Data Frames? I am always using plain int for date stamp column and I can make it an index. So i would fall in
else
clause. Despite TO DO that it might be now what I want, it is exactly what I want. Except only if I am using nano second timestamps ;(. I noticed lack ofprecision
parameter passed toto_datetime
. Patching this solve the issue for me. I could push the change but it bothers me that maybe I am doing something wrong?Expected behavior:
Data points in influx should use timestamps from time index correctly.
Actual behavior:
All dates are converted to some silly date around 1970
Specifications:
The text was updated successfully, but these errors were encountered: