TimeFrame.add_flag

TimeFrame.add_flag(flag_column_name, flag_value, expr=<Expr ['true']>, overwrite=True)[source]

Add flag value to flag column, where expression is True.

For bitwise flag columns, applies the flag via bitwise OR. overwrite is not applicable for bitwise columns.

For categorical flag columns in scalar mode, sets the column value. When overwrite is False, only rows whose current value is null are updated.

For categorical flag columns in list mode, appends the value to the list. overwrite is not applicable in list mode.

Parameters:
  • flag_column_name (str) – The name of the flag column.

  • flag_value (int | str) – The flag value to add.

  • expr (Expr | Series) – Polars expression for which rows to add flag to.

  • overwrite (bool) – Categorical scalar mode only. If True (default), replaces any existing value. If False, only updates rows whose current value is null.

Return type:

None