diff --git a/CHANGELOG.md b/CHANGELOG.md index d99a9f8c..9a7f2286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ 1. [#723](https://github.com/influxdata/influxdb-client-python/pull/723): Export public names using generated `__all__` array in `__init__.py` as per reference documentation. 1. [#725](https://github.com/influxdata/influxdb-client-python/pull/725): Start the `WritesRetry` `max_retry_time` at a request's first failure, so a strategy passed as `retries` to `InfluxDBClient` keeps retrying after `max_retry_time` has passed since it was created. 1. [#732](https://github.com/influxdata/influxdb-client-python/pull/732): Apply the `#default` annotation in `FluxCsvParser` when it comes before `#datatype`. +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] 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