Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Tags in write_points: tag_columns not optional when using json protocol #910

Open
eduisterwinkel opened this issue Nov 30, 2021 · 1 comment

Comments

@eduisterwinkel
Copy link

  • InfluxDB-python version: 5.3.1
  • Python version: tried 3.6 and 3.8
  • Operating system version: Windows 10

DataFrameClient.write_points using protocol=json currently only seem to embed tags when also tag_columns are specified. This is not what you would want, and also not as stated in the docs.

if not tag_columns:
points = [
{'measurement': measurement,
'fields':
rec.replace([np.inf, -np.inf], np.nan).dropna().to_dict(),
'time': np.int64(ts.value / precision_factor)}
for ts, (_, rec) in zip(
dataframe.index,
dataframe[field_columns].iterrows()
)
]
return points
points = [
{'measurement': measurement,
'tags': dict(list(tag.items()) + list(tags.items())),
'fields':
rec.replace([np.inf, -np.inf], np.nan).dropna().to_dict(),
'time': np.int64(ts.value / precision_factor)}
for ts, tag, (_, rec) in zip(
dataframe.index,
dataframe[tag_columns].to_dict('record'),
dataframe[field_columns].iterrows()
)
]
return points

Please make tag_columns also optional using json protocol.

@eduisterwinkel
Copy link
Author

eduisterwinkel commented Nov 30, 2021

Furthermore,

dataframe[tag_columns].to_dict('record'),

needs to be:
dataframe[tag_columns].to_dict(orient='records'),
with the 1.3.4 pandas version I am using (not sure since which version of pandas)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant