8000 DataFrameClient issue - seems does not process correctly DateTimeIndex dates · Issue #479 · influxdata/influxdb-python · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
DataFrameClient issue - seems does not process correctly DateTimeIndex dates #479
Closed
@JohnSamler

Description

@JohnSamler

I'm having problems uploading dataframes into InfluxDB, using write_points.

The problem is due to this part of the code:

File _dataframe_client.py

        # Make array of timestamp ints
        if isinstance(dataframe.index, pd.PeriodIndex):
            time = ((dataframe.index.to_timestamp().values.astype(int) /
                     precision_factor).astype(int).astype(str))
        else:
            time = ((pd.to_datetime(dataframe.index).values.astype(int) /
                     precision_factor).astype(int).astype(str))

That int cast doesn't work in my code. I tested just casting datetime's into ints and this is what i get:

    In [24]: numpy.datetime64('2016-01-05T00:00:00.000000000').astype(int)
    Out[24]: -1226113024
    In [25]: numpy.datetime64('2016-01-04T00:00:00.000000000').astype(int)
    Out[25]: 630980608
    In [26]: numpy.version.version
    Out[26]: '1.11.3'

I had to modify the code to cast to np.int64 for it to work (not using PeriodIndex):

        # Make array of timestamp ints
        if isinstance(dataframe.index, pd.PeriodIndex):
            time = ((dataframe.index.to_timestamp().values.astype(int) /
                     precision_factor).astype(int).astype(str))
        else:
            time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) /
                     precision_factor).astype(np.int64).astype(str))

Don't think the cast as coded currently is correct, or a case is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0