diff --git a/CHANGELOG.md b/CHANGELOG.md index 11eed2dcd8..186251e039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,10 @@ Changes are grouped as follows ## [Unreleased] +## [1.1.12] - 2019-10-01 ### Fixed - Fixed a bug in time series pagination where getting 100k datapoints could cause a missing id error when using include_outside_points. +- SequencesData `to_pandas` no longer returns NaN on integer zero columns. - Fixed a bug where the JSON encoder would throw circular reference errors on unknown data types, including numpy floats. ## [1.1.11] - 2019-09-23 diff --git a/cognite/client/__init__.py b/cognite/client/__init__.py index 3ed5692b10..31fdb3a92d 100644 --- a/cognite/client/__init__.py +++ b/cognite/client/__init__.py @@ -1,3 +1,3 @@ from cognite.client._cognite_client import CogniteClient -__version__ = "1.1.11" +__version__ = "1.1.12" diff --git a/cognite/client/data_classes/sequences.py b/cognite/client/data_classes/sequences.py index 7b29cb8eef..656192f670 100644 --- a/cognite/client/data_classes/sequences.py +++ b/cognite/client/data_classes/sequences.py @@ -285,7 +285,9 @@ def to_pandas(self) -> "pandas.DataFrame": pd = utils._auxiliary.local_import("pandas") return pd.DataFrame( - [[x or math.nan for x in r] for r in self.values], index=self.row_numbers, columns=self.column_external_ids + [[x if x is not None else math.nan for x in r] for r in self.values], + index=self.row_numbers, + columns=self.column_external_ids, ) @property diff --git a/tests/tests_unit/test_api/test_sequences.py b/tests/tests_unit/test_api/test_sequences.py index ce03afcff0..7e4536f4bd 100644 --- a/tests/tests_unit/test_api/test_sequences.py +++ b/tests/tests_unit/test_api/test_sequences.py @@ -119,6 +119,18 @@ def mock_get_sequence_data_two_col(rsps): yield rsps +@pytest.fixture +def mock_get_sequence_data_two_col_with_zero(rsps): + json = { + "id": 0, + "externalId": "eid", + "columns": [{"externalId": "str"}, {"externalId": "lon"}], + "rows": [{"rowNumber": 12, "values": ["string-12", 0]}], + } + rsps.add(rsps.POST, SEQ_API._get_base_url_with_base_path() + "/sequences/data/list", status=200, json=json) + yield rsps + + @pytest.fixture def mock_get_sequence_data_with_null(rsps): json = { @@ -421,6 +433,17 @@ def test_retrieve_dataframe_columns_mixed(self, mock_seq_response, mock_get_sequ assert isinstance(data, SequenceData) assert ["col1", "col2"] == list(data.to_pandas().columns) + def test_retrieve_dataframe_columns_mixed_with_zero( + self, mock_seq_response, mock_get_sequence_data_two_col_with_zero + ): + import pandas as pd + + data = SEQ_API.data.retrieve(external_id="foo", start=0, end=100) + assert isinstance(data, SequenceData) + df = data.to_pandas() + expected_df = pd.DataFrame(index=[12], data=[["string-12", 0]], columns=["str", "lon"]) + pd.testing.assert_frame_equal(expected_df, df) + def test_retrieve_dataframe_columns_many_extid(self, mock_get_sequence_data_many_columns): data = SEQ_API.data.retrieve(external_id="foo", start=1000000, end=1100000) assert isinstance(data, SequenceData)