with_columns_obs#
- Pseudobulk.with_columns_obs(*exprs, cell_types=None, excluded_cell_types=None, **named_exprs)[source]#
Equivalent to
df.with_columns()from polars, but applied to each cell type’s obs.- Parameters:
*exprs: Scalar
column(s) to add, specified as positional arguments. Accepts expression input. Strings are parsed as column names, other non-expression inputs are parsed as literals.
cell_types: str | Iterable[str] | None
one or more cell types to operate on; if None, operate on all cell types. Mutually exclusive with excluded_cell_types.
excluded_cell_types: str | Iterable[str] | None
one or more cell types to exclude from the operation; mutually exclusive with cell_types
**named_exprs: Scalar
additional columns to add, specified as keyword arguments. The columns will be renamed to the keyword used.
- Returns:
A new Pseudobulk dataset with obs[cell_type]=obs[cell_type].with_columns(*exprs, **named_exprs) for all cell types.
- Return type: