Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 02564ef

Browse files
author
Maxence Dolle
committed
Improve performance on dataframe to line conversion
1 parent 87683f4 commit 02564ef

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

influxdb/_dataframe_client.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,10 @@ def _convert_dataframe_to_lines(self,
302302
tag_df = self._stringify_dataframe(
303303
tag_df, numeric_precision, datatype='tag')
304304

305-
# prepend tag keys
306-
tag_df = tag_df.apply(
307-
lambda s: s.apply(
308-
lambda v, l: l + '=' + v if v else None, l=s.name))
309-
310-
# join tags, but leave out None values
305+
# join preprendded tags, leaving None values out
311306
tags = tag_df.apply(
312-
lambda r: ','.join(r.dropna()), axis=1)
313-
314-
# prepend comma
315-
tags = tags.apply(lambda v: ',' + v if v else '')
307+
lambda s: [',' + s.name + '=' + v if v else '' for v in s])
308+
tags = tags.sum(axis=1)
316309

317310
del tag_df
318311
else:

0 commit comments

Comments
 (0)