The question is why a query returns multiple dataframes instead of one.
Each dataframe contains several tables (table
column`, where a term Table, as far as I see, is to group timeseries.
Consider an example:
import influxdb_client
bucket = "aaa"
org = "bbb"
token = "<my token from secrets>"
# Store the URL of your InfluxDB instance
url="https://us-west-2-2.aws.cloud2.influxdata.com/"
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
query_api = client.query_api()
query = """from(bucket: "<bucket>")
|> range(start: -10m)
|> filter(fn: (r) => r["_measurement"] == "xxx")
|> filter(fn: (r) => r["_field"] == "mean_yyy")
|> aggregateWindow(every: 5m, fn: mean, createEmpty: false)
|> yield(name: "mean")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")"""
dataframes = query_api.query_data_frame(query)
What I get is two dataframes with the following columns:
Index(['result', 'table', '_start', '_stop', '_time', '_value', '_field',
'_measurement', 'host_id'],
dtype='object')
# and
Index(['result', 'table', '_start', '_stop', '_time', '_measurement',
'host_id', 'mean_yyy'],
dtype='object')
More than that, _value
from the first dataframe seems to have the same values as mean_yyy
from the second.
If I request 2 fields instead of one, this will generate 1400 dataframes. Looks really confusing