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 …])
Mac OS Sierra latest 10.12.5