Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Missing precision for to_datetime in DataFrame serializer #328

Copy link
Copy link
Closed
@Elfoniok

Description

@Elfoniok
Issue body actions

Steps to reproduce:

  1. Create a pandas Data Frame with non nano seconds timestamps. Set Data Frame with a time column as an index.
  2. Set the precision to 's' in my case cause timestamps are with seconds precision. Use write api to write it.
  3. The timestamps will be converted to 1970.

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 of precision parameter passed to to_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:

  • Client Version:1.20
  • InfluxDB Version:2.0.8
  • Platform:5.4.0-81-generic 18.04.1-Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.