Код: Выделить всё
with_columns
Код: Выделить всё
df.with_columns(
[
.alias('step_1'), # here I want step_1 to become a column in the output table
temporary_variable = , # here I want this variable not to be present in the output table
pl.col(['step_1']).some_function(temporary_variable).alias('step_2'), # this column's expression uses both the first column: 'step_1' and temporary_variable
pl.col(...).some_other_function(temporary_variable).alias('another_column') # temporary_variable might need to be used in multiple column's expression, being able to declare the temporary variable and reuse it makes the code shorter, more modular and avoids copy pasts
]
)
Подробнее здесь: https://stackoverflow.com/questions/766 ... -in-polars