From 0277c3fcc5b40d9d70668fbbf02c438b2a867d23 Mon Sep 17 00:00:00 2001 From: Ryu Hosung Date: Mon, 3 Aug 2020 18:47:15 +0900 Subject: [PATCH 1/2] Update time_precision param values in docstring Clearly state nanosecond and hour precision support for functions `send_packet` and `write_points` in docstring. Nanosecond precision support was added in commits 02ddf0e783d57762341fbf0662ac3b6c9696dcbc and c92bb4e4a5684611dc65b53c5791fae4bce5d94b, but the change was not reflected to the docstring. --- influxdb/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/influxdb/client.py b/influxdb/client.py index df9ef966..38590b1d 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -561,7 +561,8 @@ def write_points(self, :type points: (if protocol is 'json') list of dicts, where each dict represents a point. (if protocol is 'line') sequence of line protocol strings. - :param time_precision: Either 's', 'm', 'ms' or 'u', defaults to None + :param time_precision: Either 'n', 'u', 'ms', 's', 'm' or 'h', + defaults to None :type time_precision: str :param database: the database to write the points to. Defaults to the client's current database @@ -1177,7 +1178,8 @@ def send_packet(self, packet, protocol='json', time_precision=None): (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data, either 'json' or 'line' :type protocol: str - :param time_precision: Either 's', 'm', 'ms' or 'u', defaults to None + :param time_precision: Either 'n', 'u', 'ms', 's', 'm' or 'h', + defaults to None :type time_precision: str """ if protocol == 'json': From b71f29cdd04ada3283b2ede7ac385cdbe62c8245 Mon Sep 17 00:00:00 2001 From: Ryu Hosung Date: Tue, 4 Aug 2020 11:23:26 +0900 Subject: [PATCH 2/2] Use exact parameter value for Dataframe.to_dict The documentation of `pandas.DataFrame.to_dict` states that "Abbreviations are allowed." for parameter `orient`. However, it induces a warning since the exact value is "records", which causes the test to fail. References: Documentation: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_dict.html Related pandas code: https://github.com/pandas-dev/pandas/blob/d9fff2792bf16178d4e450fe7384244e50635733/pandas/core/frame.py#L1474 --- 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 e7ae9c17..1363cbf0 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -305,7 +305,7 @@ def _convert_dataframe_to_json(dataframe, 'time': np.int64(ts.value / precision_factor)} for ts, tag, (_, rec) in zip( dataframe.index, - dataframe[tag_columns].to_dict('record'), + dataframe[tag_columns].to_dict('records'), dataframe[field_columns].iterrows() ) ]