pipolars.PIQuery¶
- class pipolars.PIQuery[source]¶
Bases:
objectFluent query builder for PI data.
This class provides a method-chaining interface for building PI data queries in a readable, declarative style.
Example
>>> df = client.query("SINUSOID") \ ... .time_range("*-1d", "*") \ ... .recorded() \ ... .with_quality() \ ... .to_dataframe()
>>> df = client.query(["TAG1", "TAG2"]) \ ... .last(hours=24) \ ... .interpolated(interval="15m") \ ... .pivot() \ ... .to_dataframe()
>>> df = client.query("SINUSOID") \ ... .time_range("*-7d", "*") \ ... .summary(SummaryType.AVERAGE, SummaryType.MAXIMUM) \ ... .to_dataframe()
Methods
__init__(client, tags)Initialize the query builder.
boundary(boundary_type)Set the boundary type for recorded values.
filter(expression)Set a filter expression.
interpolated([interval])Query for interpolated values.
last([hours, days, minutes, seconds])Set time range to the last N time units.
limit(max_count)Limit the number of values returned.
pivot()Pivot results to wide format (tags as columns).
plot([intervals])Query for plot-optimized values.
recorded([max_count])Query for recorded values.
snapshot()Query for current snapshot values.
summary(*summary_types)Query for summary statistics.
Set time range to this month.
Set time range to this week.
time_range(start, end)Set the time range for the query.
Execute the query and return a Polars DataFrame.
Execute the query and return a Polars LazyFrame.
today()Set time range to today.
Include quality information in results.
Exclude quality information from results.
Set time range to yesterday.
- summary(*summary_types)[source]¶
Query for summary statistics.
- Parameters:
*summary_types (SummaryType) – Summary types to calculate
- Returns:
Self for method chaining
- Return type:
- snapshot()[source]¶
Query for current snapshot values.
- Returns:
Self for method chaining
- Return type:
- with_quality()[source]¶
Include quality information in results.
- Returns:
Self for method chaining
- Return type:
- without_quality()[source]¶
Exclude quality information from results.
- Returns:
Self for method chaining
- Return type:
- boundary(boundary_type)[source]¶
Set the boundary type for recorded values.
- Parameters:
boundary_type (BoundaryType) – Boundary type to use
- Returns:
Self for method chaining
- Return type:
- pivot()[source]¶
Pivot results to wide format (tags as columns).
- Returns:
Self for method chaining
- Return type:
- to_dataframe()[source]¶
Execute the query and return a Polars DataFrame.
- Returns:
DataFrame with query results
- Return type:
DataFrame