Skip to content

fix(data_frame): parsing empty query result value as numpy.NaN #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Breaking Changes

This release disables using of the HTTP proxy environment variables `HTTP_PROXY` and `HTTPS_PROXY` for the asynchronous HTTP client.
This release disables using of the HTTP proxy environment variables `HTTP_PROXY` and `HTTPS_PROXY` for the asynchronous HTTP client.
The proxy environment variables must be explicitly enabled in the client's configuration:

```python
Expand All @@ -15,6 +15,7 @@ async with InfluxDBClientAsync(url="http://localhost:8086", token="my-token", or

### Bug Fixes
1. [#583](https://github.com/influxdata/influxdb-client-python/pull/583): Async HTTP client doesn't always use `HTTP_PROXY`/`HTTPS_PROXY` environment variables. [async/await]
1. [#584](https://github.com/influxdata/influxdb-client-python/pull/584): Parsing empty query result value as `numpy.NaN`

## 1.36.1 [2023-02-23]

Expand Down
3 changes: 3 additions & 0 deletions influxdb_client/client/flux_csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ def _to_value(self, str_val, column):
if str_val == '' or str_val is None:
default_value = column.default_value
if default_value == '' or default_value is None:
if self._serialization_mode is FluxSerializationMode.dataFrame:
from ..extras import np
return self._to_value(np.nan, column)
return None
return self._to_value(default_value, column)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_FluxCSVParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@ def test_pandas_column_datatype(self):
self.assertEqual('bool', df.dtypes['value4'].name)
self.assertEqual('float64', df.dtypes['value5'].name)

def test_pandas_null_bool_types(self):
data = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,boolean\n" \
"#group,false,false,true,true,true,true,true,true,false\n" \
"#default,_result,,,,,,,,\n" \
",result,table,_start,_stop,_field,_measurement,host,region,value\n" \
",,0,1977-09-21T00:12:43.145224192Z,2018-07-16T11:21:02.547596934Z,free,mem,A,west,true\n" \
",,0,1977-09-21T00:12:43.145224192Z,2018-07-16T11:21:02.547596934Z,free,mem,A,west,\n"

parser = self._parse(data=data, serialization_mode=FluxSerializationMode.dataFrame,
response_metadata_mode=FluxResponseMetadataMode.full)
df = list(parser.generator())[0]
self.assertEqual('bool', df.dtypes['value'].name)

def test_parse_without_datatype(self):
data = ",result,table,_start,_stop,_field,_measurement,host,region,_value2,value1,value_str\n" \
",,0,1677-09-21T00:12:43.145224192Z,2018-07-16T11:21:02.547596934Z,free,mem,A,west,121,11,test\n" \
Expand Down