model_element
ModelElement(data, **kwargs)
Bases: ABC
Source code in src\pyoframe\model_element.py
dimensions
property
The names of the data's dimensions.
Examples:
dimensions_unsafe
property
Same as dimensions
but returns an empty list if there are no dimensions instead of None.
When unsure, use dimensions
instead since the type checker forces users to handle the None case (no dimensions).
shape
property
The number of indices in each dimension.
Examples:
ModelElementWithId(data, **kwargs)
Bases: ModelElement
Provides a method that assigns a unique ID to each row in a DataFrame. IDs start at 1 and go up consecutively. No zero ID is assigned since it is reserved for the constant variable term. IDs are only unique for the subclass since different subclasses have different counters.
Source code in src\pyoframe\model_element.py
SupportPolarsMethodMixin
Bases: ABC
pick(**kwargs)
Filters elements by the given criteria and then drops the filtered dimensions.
Examples:
>>> m = pf.Model()
>>> m.v = pf.Variable([{"hour": ["00:00", "06:00", "12:00", "18:00"]}, {"city": ["Toronto", "Berlin", "Paris"]}])
>>> m.v.pick(hour="06:00")
<Expression size=3 dimensions={'city': 3} terms=3>
[Toronto]: v[06:00,Toronto]
[Berlin]: v[06:00,Berlin]
[Paris]: v[06:00,Paris]
>>> m.v.pick(hour="06:00", city="Toronto")
<Expression size=1 dimensions={} terms=1>
v[06:00,Toronto]