diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 907db2cb..afb72581 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -8,6 +8,7 @@ import math from collections import defaultdict +import re import pandas as pd import numpy as np @@ -31,6 +32,16 @@ def _pandas_time_unit(time_precision): def _escape_pandas_series(s): return s.apply(lambda v: _escape_tag(v)) +__TIMESTAMP_FIX_RE = re.compile(r"\d+-\d\d-\d\dT\d\d:\d\d:\d\dZ") + +def _fix_timestamp_format(x): + """Fixes timestamp without fractions of seconds to have them.""" + match = re.match(__TIMESTAMP_FIX_RE, x) + if match: + x = x[:-1] + ".000000Z" + return x + return x + class DataFrameClient(InfluxDBClient): """DataFrameClient instantiates InfluxDBClient to connect to the backend. @@ -219,6 +230,7 @@ def _to_dataframe(self, rs, dropna=True, data_frame_index=None): else: key = (name, tuple(sorted(tags.items()))) df = pd.DataFrame(data) + df.time = df.time.map(_fix_timestamp_format) df.time = pd.to_datetime(df.time) if data_frame_index: 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