where
relationalai.semantics
where(*args: Statement) -> FragmentReturn a fragment filtered by the given conditions.
This is a convenience wrapper around Model.where that operates on
the single active model. It returns a composable Fragment that can be further
refined with Fragment.define, Fragment.require, and
Fragment.select. You can also add additional filters by chaining
Fragment.where on an existing fragment.
If you have more than one model, call Model.where on the specific model instead.
Parameters
Section titled “Parameters”-
(*argsStatement, default:()) - One or moresemantics.frontend.base.Statementitems to use as filter conditions. Common examples include:- Comparison operators:
Person.age > 21 - String operators:
Person.name.startswith("A") - Logical operators:
not_(Person.name.startswith("A")) - Property existence:
Person.age(filters to entities with an age property)
- Comparison operators:
Returns
Section titled “Returns”Fragment- A composable fragment representing the filter(s).
Raises
Section titled “Raises”relationalai.util.error.RAIException- If there is no active model, or if multiple models exist and the active model would be ambiguous.
Examples
Section titled “Examples”Filter and select:
>>> from relationalai.semantics import Model, where, select>>> m = Model()>>> Person = m.Concept("Person")>>> where(Person.age > 21).select(Person.name).to_df()Filter a definition:
>>> Adult = m.Concept("Adult", extends=[Person])>>> where(Person.age >= 18).define(Adult(Person))Multiple conditions are combined with AND:
>>> where(Person.age > 21, Person.name.startswith("A")).select(Person.name).to_df()Chained filters are also combined with AND:
>>> where(Person.age > 21).where(Person.name.startswith("A")).select(Person.name).to_df()Referenced By
Section titled “Referenced By”RelationalAI Documentation └── Release Notes └── Python API Release Notes └── What’s New in Version 1.0.0 └── Breaking Changes