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 write with nan in first column error #657
Open
Description
Nan values not handled correctly in first column of the dataframe to write when using DataFrameClient. An extra comma is added before fields with line protocol.
Example to trigger the bug:
from influxdb import DataFrameClient
import pandas as pd
import numpy as np
import requests_mock
df_fail = pd.DataFrame(
{'a': [np.NaN, 2, 3], 'b': [4, np.NaN, 6], 'c': [7, 8, np.NaN]},
index=pd.DatetimeIndex(start='2011-07-03', periods=3, freq='d'),
dtype=np.float32)
expected_body = b'foo b=4.0,c=7.0 1309651200000000000\nfoo a=2.0,c=8.0 1309737600000000000\nfoo a=3.0,b=6.0 1309824000000000000\n'
with requests_mock.Mocker() as m:
m.register_uri(requests_mock.POST,
"http://localhost:8086/write",
status_code=204)
cli = DataFrameClient(database='db')
cli.write_points(df_fail, 'foo')
body = m.last_request.body
assert body == expected_body, body
Output:
AssertionError: b'foo ,b=4.0,c=7.0 1309651200000000000\nfoo a=2.0,c=8.0 1309737600000000000\nfoo a=3.0,b=6.0 1309824000000000000\n'
Metadata
Metadata
Assignees
Labels
No labels