InfluxDB/Python: NaN in a Pandas dataframe not supported by DataFrameClient.write_points?

influxdb
#1

By default, pandas’ read_csv replaces missing values in a dataframe (df) by NaN, but DataFrameClient.write_points() fails when it attempts to store such dataframe in influxDB spitting out the following error message for each line:

unable to parse ‘…,Alias=nan 1496160000000000000’: invalid number"
Note: the ‘…’ represents the expected measurement, tags KV, fields KV

Is it the expected behavior? So, there may be a way to tell write_points to store NaN value with InfluxDB equivalent.
The only way I found so far, was to get rid of the field=“NaN” in passing the argument ‘na_filter=False’ to pd.read_csv.

Working code (removing na_filter=False will fail with the error message above):

df = pd.read_csv(path_to_file, header = None, na_filter=False)
client = DataFrameClient(host, port, user, passwd, database)
client.write_points(df, measurement=table, tag_columns = [ … a set of tags …])

Target system:
Mac OS Sierra latest 10.12.5
Python 3.6
influxdb (4.1.0)
pandas (0.19.2)

Thanks,
Lionel

#2

This is an open issue on the InfluxDB Python repo. It also looks like theres a PR up that fixes this. I’ve gone ahead and referenced this post there as well. Thanks for the report!