From 4e27dcc47f02d8370d406962abb2bad899d8345a Mon Sep 17 00:00:00 2001 From: taltal-beep Date: Mon, 2 Nov 2026 09:19:48 +0200 Subject: [PATCH 1/2] fix(write): match DataFrame timestamp column by exact name The serializer tested 'key in timestamp_column', a substring check, so a field column whose name is part of the timestamp column name (Open with OpenTime) was treated as the timestamp and silently dropped. When every field matched that way the serializer raised IndexError. Closes #592 --- CHANGELOG.md | 1 + .../client/write/dataframe_serializer.py | 2 +- tests/test_WriteApiDataFrame.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6775c6..f2f75348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ 1. [#714](https://github.com/influxdata/influxdb-client-python/pull/714): Implement `WriteApi.flush()` to force pending batch writes without disposing the API (mirrors C#/Java batch writer). 1. [#715](https://github.com/influxdata/influxdb-client-python/pull/715): Accept numeric zero for `RangeThreshold.min`/`max` and greater/lesser `value` (identity checks vs `None`, not truthiness); cover create-check serialization. 1. [#720](https://github.com/influxdata/influxdb-client-python/pull/720): Prevent the `api_client` class from raising exceptions while the Python interpreter clears the client state during shutdown. +1. [#592](https://github.com/influxdata/influxdb-client-python/issues/592): Match `data_frame_timestamp_column` by exact column name, so a field whose name is part of the timestamp column name (e.g. `Open` with `OpenTime`) is no longer dropped. ## 1.50.0 [2026-01-23] diff --git a/influxdb_client/client/write/dataframe_serializer.py b/influxdb_client/client/write/dataframe_serializer.py index ccc198ac..c4ae40dd 100644 --- a/influxdb_client/client/write/dataframe_serializer.py +++ b/influxdb_client/client/write/dataframe_serializer.py @@ -174,7 +174,7 @@ def __init__(self, data_frame, point_settings, precision=DEFAULT_WRITE_PRECISION key_value = f',{key_format}={{str({val_format}).translate(_ESCAPE_KEY)}}' tags.append(key_value) continue - elif timestamp_column is not None and key in timestamp_column: + elif timestamp_column is not None and key == timestamp_column: timestamp_index = field_index continue diff --git a/tests/test_WriteApiDataFrame.py b/tests/test_WriteApiDataFrame.py index 1e1f0ad3..ec667ed9 100644 --- a/tests/test_WriteApiDataFrame.py +++ b/tests/test_WriteApiDataFrame.py @@ -459,6 +459,23 @@ def test_use_timestamp_from_specified_column(self): self.assertEqual('test value1=10i,value2=30i 1586044800000000000', points[0]) self.assertEqual('test value1=20i,value2=40i 1588636800000000000', points[1]) + def test_timestamp_column_name_contains_field_name(self): + from influxdb_client.extras import pd + data_frame = pd.DataFrame(data={ + 'OpenTime': ['2020-04-05', '2020-05-05'], + 'Open': [10, 20], + 'Time': [30, 40], + }, index=['A', 'B']) + + points = data_frame_to_list_of_points(data_frame=data_frame, + data_frame_measurement_name="test", + data_frame_timestamp_column="OpenTime", + point_settings=PointSettings()) + + self.assertEqual(2, len(points)) + self.assertEqual('test Open=10i,Time=30i 1586044800000000000', points[0]) + self.assertEqual('test Open=20i,Time=40i 1588636800000000000', points[1]) + def test_str_format_for_timestamp(self): from influxdb_client.extras import pd From 65f416269e49a308961c992297660531078186dc Mon Sep 17 00:00:00 2001 From: taltal-beep Date: Mon, 2 Nov 2026 09:31:30 +0200 Subject: [PATCH 2/2] docs: link CHANGELOG entry to #734 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2f75348..15b6c471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ 1. [#714](https://github.com/influxdata/influxdb-client-python/pull/714): Implement `WriteApi.flush()` to force pending batch writes without disposing the API (mirrors C#/Java batch writer). 1. [#715](https://github.com/influxdata/influxdb-client-python/pull/715): Accept numeric zero for `RangeThreshold.min`/`max` and greater/lesser `value` (identity checks vs `None`, not truthiness); cover create-check serialization. 1. [#720](https://github.com/influxdata/influxdb-client-python/pull/720): Prevent the `api_client` class from raising exceptions while the Python interpreter clears the client state during shutdown. -1. [#592](https://github.com/influxdata/influxdb-client-python/issues/592): Match `data_frame_timestamp_column` by exact column name, so a field whose name is part of the timestamp column name (e.g. `Open` with `OpenTime`) is no longer dropped. +1. [#734](https://github.com/influxdata/influxdb-client-python/pull/734): Match `data_frame_timestamp_column` by exact column name, so a field whose name is part of the timestamp column name (e.g. `Open` with `OpenTime`) is no longer dropped. ## 1.50.0 [2026-01-23]