Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: influxdata/influxdb-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: TreonOy/influxdb-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 18, 2024

  1. Copy the full SHA
    5dfc723 View commit details
Showing with 12 additions and 0 deletions.
  1. +12 −0 influxdb/_dataframe_client.py
12 changes: 12 additions & 0 deletions influxdb/_dataframe_client.py
Original file line number Diff line number Diff line change
@@ -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: