From 8a668941dcf40ec64044b7b4d9ef84accd8d70e1 Mon Sep 17 00:00:00 2001 From: dennisn Date: Fri, 27 Apr 2018 19:30:03 +0300 Subject: [PATCH 01/10] Remove comment as issues have been resolved --- examples/tutorial_pandas.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tutorial_pandas.py b/examples/tutorial_pandas.py index b5fb8f79..67a5457d 100644 --- a/examples/tutorial_pandas.py +++ b/examples/tutorial_pandas.py @@ -12,7 +12,6 @@ def main(host='localhost', port=8086): user = 'root' password = 'root' dbname = 'demo' - # Temporarily avoid line protocol time conversion issues #412, #426, #431. protocol = 'json' client = DataFrameClient(host, port, user, password, dbname) From fae177c2b6d41e95823aa14d8e09f6cbf53d2315 Mon Sep 17 00:00:00 2001 From: dennisn Date: Thu, 3 May 2018 12:14:13 +0300 Subject: [PATCH 02/10] Parse column names in a dataframe to handle spaces in tag of field keys --- influxdb/_dataframe_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 86b582af..e297e09e 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -113,6 +113,7 @@ def write_points(self, return True if protocol == 'line': + dataframe = dataframe.rename(columns={item:_escape_tag(item) for item in dataframe.columns}) points = self._convert_dataframe_to_lines( dataframe, measurement=measurement, From fcb02c2d5375fb6c6341e1e7fa58419a638d4081 Mon Sep 17 00:00:00 2001 From: dennisn Date: Thu, 3 May 2018 14:06:45 +0300 Subject: [PATCH 03/10] Patch for ERROR: Test failed write points from df with series --- influxdb/_dataframe_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index e297e09e..bab9408c 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -113,7 +113,6 @@ def write_points(self, return True if protocol == 'line': - dataframe = dataframe.rename(columns={item:_escape_tag(item) for item in dataframe.columns}) points = self._convert_dataframe_to_lines( dataframe, measurement=measurement, @@ -290,6 +289,7 @@ def _convert_dataframe_to_lines(self, 'PeriodIndex.') # Create a Series of columns for easier indexing + dataframe = dataframe.rename(columns={item:_escape_tag(item) for item in dataframe.columns}) column_series = pd.Series(dataframe.columns) if field_columns is None: From 86439843829f496133c1b0b9f7d72a82240b5edd Mon Sep 17 00:00:00 2001 From: dennisn Date: Thu, 3 May 2018 14:33:21 +0300 Subject: [PATCH 04/10] Patch for flake8 issues(E231, E501) --- influxdb/_dataframe_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index bab9408c..868e1f5f 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -289,7 +289,8 @@ def _convert_dataframe_to_lines(self, 'PeriodIndex.') # Create a Series of columns for easier indexing - dataframe = dataframe.rename(columns={item:_escape_tag(item) for item in dataframe.columns}) + dataframe = dataframe.rename( + columns={item: _escape_tag(item) for item in dataframe.columns}) column_series = pd.Series(dataframe.columns) if field_columns is None: From 009bd35af1d1f036be7d32510afe707839a7feb4 Mon Sep 17 00:00:00 2001 From: dennisn Date: Fri, 4 May 2018 16:30:20 +0300 Subject: [PATCH 05/10] Test case for spaces in column names --- influxdb/tests/dataframe_client_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index 5a717f5c..0ffe0c87 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -81,6 +81,25 @@ def test_dataframe_write_points_with_whitespace_measurement(self): cli.write_points(dataframe, 'meas with space') self.assertEqual(m.last_request.body, expected) + def test_dataframe_write_points_with_whitespace_in_column_names(self): + """write_points should escape white space in column names (tag and field names).""" + now = pd.Timestamp('1970-01-01 00:00+00:00') + dataframe = pd.DataFrame(data=[["1", 1, 1.0], ["2", 2, 2.0]], + index=[now, now + timedelta(hours=1)], + columns=["column one", "column two", "column three"]) + expected = ( + b"foo column\\ one=\"1\",column\\ two=1i,column\\ three=1.0 0\n" + b"foo column\\ one=\"2\",column\\ two=2i,column\\ three=2.0 " + b"3600000000000\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(dataframe, 'foo') + self.assertEqual(m.last_request.body, expected) + def test_write_points_from_dataframe_with_none(self): """Test write points from df in TestDataFrameClient object.""" now = pd.Timestamp('1970-01-01 00:00+00:00') From deedb06c0be66d3d6bef794cbf48558325a6ea0b Mon Sep 17 00:00:00 2001 From: dennisn Date: Fri, 4 May 2018 16:47:02 +0300 Subject: [PATCH 06/10] flake8 issues --- influxdb/tests/dataframe_client_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index 0ffe0c87..33c85b77 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -82,16 +82,17 @@ def test_dataframe_write_points_with_whitespace_measurement(self): self.assertEqual(m.last_request.body, expected) def test_dataframe_write_points_with_whitespace_in_column_names(self): - """write_points should escape white space in column names (tag and field names).""" + """write_points should escape white space in column names.""" now = pd.Timestamp('1970-01-01 00:00+00:00') dataframe = pd.DataFrame(data=[["1", 1, 1.0], ["2", 2, 2.0]], index=[now, now + timedelta(hours=1)], - columns=["column one", "column two", "column three"]) + columns=["column one", "column two", + "column three"]) expected = ( b"foo column\\ one=\"1\",column\\ two=1i,column\\ three=1.0 0\n" b"foo column\\ one=\"2\",column\\ two=2i,column\\ three=2.0 " b"3600000000000\n" - ) + ) with requests_mock.Mocker() as m: m.register_uri(requests_mock.POST, "http://localhost:8086/write", From 6ec7ebaae3a5275d310d87ed3954d86421c8ec76 Mon Sep 17 00:00:00 2001 From: dennisn Date: Fri, 4 May 2018 16:53:37 +0300 Subject: [PATCH 07/10] flake8 issues: trailing wspace --- influxdb/tests/dataframe_client_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index 33c85b77..78f5437f 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -86,7 +86,7 @@ def test_dataframe_write_points_with_whitespace_in_column_names(self): now = pd.Timestamp('1970-01-01 00:00+00:00') dataframe = pd.DataFrame(data=[["1", 1, 1.0], ["2", 2, 2.0]], index=[now, now + timedelta(hours=1)], - columns=["column one", "column two", + columns=["column one", "column two", "column three"]) expected = ( b"foo column\\ one=\"1\",column\\ two=1i,column\\ three=1.0 0\n" From fdb3e7ac7a8f034e837b377a1c74bd4309c65ad4 Mon Sep 17 00:00:00 2001 From: dennisn Date: Sat, 5 May 2018 12:57:17 +0300 Subject: [PATCH 08/10] Testing if test case would catch a regression --- influxdb/_dataframe_client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 868e1f5f..86b582af 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -289,8 +289,6 @@ def _convert_dataframe_to_lines(self, 'PeriodIndex.') # Create a Series of columns for easier indexing - dataframe = dataframe.rename( - columns={item: _escape_tag(item) for item in dataframe.columns}) column_series = pd.Series(dataframe.columns) if field_columns is None: From 1b726f20d4dddc18c961f11b8fa55c18d20e9088 Mon Sep 17 00:00:00 2001 From: dennisn Date: Sat, 5 May 2018 13:10:10 +0300 Subject: [PATCH 09/10] Test catches a regressed build --- influxdb/_dataframe_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 86b582af..868e1f5f 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -289,6 +289,8 @@ def _convert_dataframe_to_lines(self, 'PeriodIndex.') # Create a Series of columns for easier indexing + dataframe = dataframe.rename( + columns={item: _escape_tag(item) for item in dataframe.columns}) column_series = pd.Series(dataframe.columns) if field_columns is None: From 61ecb58fa4944244c08a75a12c5d53d1a2ecf88e Mon Sep 17 00:00:00 2001 From: dennisn Date: Sat, 5 May 2018 15:54:45 +0300 Subject: [PATCH 10/10] Re-run the build --- influxdb/_dataframe_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 868e1f5f..2444a77f 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -288,9 +288,9 @@ def _convert_dataframe_to_lines(self, raise TypeError('Must be DataFrame with DatetimeIndex or ' 'PeriodIndex.') - # Create a Series of columns for easier indexing dataframe = dataframe.rename( columns={item: _escape_tag(item) for item in dataframe.columns}) + # Create a Series of columns for easier indexing column_series = pd.Series(dataframe.columns) if field_columns is None: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy