KitDocumentation

ColumnOp

Simplifies performing mathematical operations between columns and applying functions to a column. ColumnOp understands how to apply python syntax and call column names for operations. Additionally, ColumnOp can format function calls and with columns and lambda statements to pass all rows of a column to a function.

Options

operation: Specifies the operation to perform on columns
where: Condition to be met for the operation to be applied to a row.

Examples

Example 1 - Multiply Column Based on a Condition

Perform a column-level operation where values are updated only if a specified condition is met. In this case, we multiply AccountBalance by 10 for all rows where the CustomerAge is greater than 35. This allows for conditional transformations based on row-level attributes.
#> ColumnOp AccountBalance * 10 --where CustomerAge > 35
AFLEFT 
whereCondition = bankTransactionsDf['CustomerAge'] > 35
bankTransactionsDf['AccountBalance'][whereCondition] = bankTransactionsDf['AccountBalance'] * 10 AFRIGHT

Example 2 - Set Column Value Based on a Condition

Sometimes we want to overwrite a column value if a condition is met. Here, we set LoginAttempts to 6 for all customers under the age of 20. This kind of logic is often used to reset, flag, or standardize values for specific customer segments.
#> ColumnOp LoginAttempts = 6 --where CustomerAge < 20
AFLEFT 
whereCondition = bankTransactionsDf['CustomerAge'] < 20
bankTransactionsDf['LoginAttempts'][whereCondition] = 6 AFRIGHT