In the python data science ecosystem method chaining is a common way of simplifying query creation and data manipulations.
- Polars Expressions and Contexts
- Pandas has similar options
I came across a recent odata python client, odata-bc, that implemented method chaining for complex queries that resulted in very readable code:
from odata import OData, Q
from datetime import date
client = OData("http://localhost:42001/api/data-store/v1/odata")
test_results = (
client("TestResults")
.filter((Q("StartDateTime") >= date(2026, 1, 1)) & (Q("StartDateTime") <= date(2026, 12, 31)))
.select("Name","StartDateTime" ,"EndDateTime" ,"Outcome", "OperatorId", "TestStationId", "Id")
.orderby("StartDateTime")
.fetch()
)
test_results.head()
This is just intended as illustration of the concept, the odata-bc library has its limitations with no public repository or documentations.
AB#3752518