Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query_data_frame returns a list of data frames #589

Open
NicoCaldo opened this issue Jun 30, 2023 · 2 comments
Open

query_data_frame returns a list of data frames #589

NicoCaldo opened this issue Jun 30, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@NicoCaldo
Copy link

NicoCaldo commented Jun 30, 2023

Specifications

  • Client Version: 1.36.1
  • InfluxDB Version: 2.71
  • Platform: Linux

Code sample to reproduce problem

Push a series of data and get it back via API query

for i in range(0,600000):
   temperatura += 1
   point = (
   	Point("Postazione1")
   	.tag("TipoTest", 1)
   	.field("Temperatura", temperatura))
   DBresponse = write_api.write(bucket=bucket, org=config.influx_org, record=point)
   time.sleep(.01)

Then get back the data with API AND THE QUERY BELOW

from(bucket: “Bed1”)
|> range(start: 2023-06-22T14:10:36.106Z, stop: 2023-06-22T14:29:12.154Z)
|> filter(fn: (r) => r[“_measurement”] == “Postazione1”)
|> filter(fn: (r) => r[“TipoTest”] == “1”)
|> filter(fn: (r) => r[“_field”] == “Temperatura”)
|> aggregateWindow(every: 1s, fn: mean, createEmpty: false)
|> yield(name: “mean”)
|> pivot(rowKey:[“_time”], columnKey: [“_field”], valueColumn: “_value”)
|> keep(columns:[“_time”, “Temperatura”])

client = InfluxDBClient(url=influx_url, token=influx_token, org=influx_org, debug=False)
df = client.query_api().query_data_frame(org=influx_org, query=query)

For some reason, df is a list of, in my case, 2 data frames so I can access df[0] and df[1]

Why I got 2 data frames and not one?

Expected behavior

Return a single data frame with all the data from my measure

Actual behavior

Return two data frames

Additional info

No response

@NicoCaldo NicoCaldo added the bug Something isn't working label Jun 30, 2023
@powersj
Copy link
Contributor

powersj commented Jun 30, 2023

Why I got 2 data frames and not one?

What are in those two data frames?

Your write function writes 1000 points, one at a time, does that take more than 1 second, such that your aggregation window covers 2 seconds?

@NicoCaldo
Copy link
Author

Why I got 2 data frames and not one?

What are in those two data frames?

Your write function writes 1000 points, one at a time, does that take more than 1 second, such that your aggregation window covers 2 seconds?

I upload data continuously for a period of time of several minutes so, imagine the for loop for such period of time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants