diff --git a/src/homepageExperience/components/steps/python/ExecuteAggregateQuerySql.tsx b/src/homepageExperience/components/steps/python/ExecuteAggregateQuerySql.tsx index 8a6e260bb9..e4d300dabd 100644 --- a/src/homepageExperience/components/steps/python/ExecuteAggregateQuerySql.tsx +++ b/src/homepageExperience/components/steps/python/ExecuteAggregateQuerySql.tsx @@ -19,16 +19,16 @@ type OwnProps = { export const ExecuteAggregateQuerySql = (props: OwnProps) => { const {bucket} = props - const sqlSnippet = `SELECT mean(count) -FROM 'census' -WHERE time > now() - '10m'` + const sqlSnippet = `SELECT mean(ants) as ant_mean, mean(bees) as bee_mean + FROM census + WHERE time >= now() - 24h` - const querySnippet = `query = """SELECT mean(count) -FROM 'census' -WHERE time > now() - '10m'""" + const querySnippet = `query = """SELECT mean(ants) as ant_mean, mean(bees) as bee_mean + FROM census + WHERE time >= now() - 24h""" # Execute the query -table = client.query(query=query, database="${bucket}", language='influxql') ) +table = client.query(query=query, database="${bucket}", language='influxql') # Convert to dataframe df = table.to_pandas().sort_values(by="time") @@ -40,7 +40,7 @@ print(df)

Execute an Aggregate Query

Aggregate functions @@ -58,7 +58,7 @@ print(df)

In this example, we use the{' '} mean() function - to calculate the average value of data points in the last 10 minutes. + to calculate the average value of data points in the last 24 hours.

Run the following: diff --git a/src/homepageExperience/components/steps/python/ExecuteQuerySql.tsx b/src/homepageExperience/components/steps/python/ExecuteQuerySql.tsx index cdc8dfd439..803590a51c 100644 --- a/src/homepageExperience/components/steps/python/ExecuteQuerySql.tsx +++ b/src/homepageExperience/components/steps/python/ExecuteQuerySql.tsx @@ -15,17 +15,15 @@ export const ExecuteQuerySql = (props: OwnProps) => { const {bucket} = props const sqlSnippet = `SELECT * -FROM 'census' -WHERE time >= now() - interval '1 hour' -AND ('bees' IS NOT NULL OR 'ants' IS NOT NULL)` +FROM census +WHERE time >= now() - interval '1 hour'` const query = `query = """SELECT * -FROM 'census' -WHERE time >= now() - interval '24 hours' -AND ('bees' IS NOT NULL OR 'ants' IS NOT NULL)""" +FROM census +WHERE time >= now() - interval '24 hours'""" # Execute the query -table = client.query(query=query, database="${bucket}", language='sql') ) +table = client.query(query=query, database="${bucket}", language='sql') # Convert to dataframe df = table.to_pandas().sort_values(by="time")