Skip to content

Missing precision for to_datetime in DataFrame serializer #328

@Elfoniok

Description

@Elfoniok

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 request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy