Set
Bases: BaseOperableBlock
A set which can then be used to index variables.
Examples:
>>> pf.Set(x=range(2), y=range(3))
<Set 'unnamed' height=6>
┌─────┬─────┐
│ x ┆ y │
│ (2) ┆ (3) │
╞═════╪═════╡
│ 0 ┆ 0 │
│ 0 ┆ 1 │
│ 0 ┆ 2 │
│ 1 ┆ 0 │
│ 1 ┆ 1 │
│ 1 ┆ 2 │
└─────┴─────┘
Methods:
Name | Description |
---|---|
drop |
Returns a new Set with the given dimensions dropped. |
to_expr |
Converts the Set to an Expression equal to 1 for each index. |
Source code in pyoframe/_core.py
drop(*dims: str) -> Set
Returns a new Set with the given dimensions dropped.
Only unique rows are kept in the resulting Set.
Examples:
>>> xy = pf.Set(x=range(3), y=range(2))
>>> xy
<Set 'unnamed' height=6>
┌─────┬─────┐
│ x ┆ y │
│ (3) ┆ (2) │
╞═════╪═════╡
│ 0 ┆ 0 │
│ 0 ┆ 1 │
│ 1 ┆ 0 │
│ 1 ┆ 1 │
│ 2 ┆ 0 │
│ 2 ┆ 1 │
└─────┴─────┘
>>> x = xy.drop("y")
>>> x
<Set 'unnamed_set.drop(…)' height=3>
┌─────┐
│ x │
│ (3) │
╞═════╡
│ 0 │
│ 1 │
│ 2 │
└─────┘
Source code in pyoframe/_core.py
to_expr() -> Expression
Converts the Set to an Expression equal to 1 for each index.
Useful when multiplying a Set by an Expression.
Comments