Ciaren

Calculated column

Calculated column — calculatedColumn

Add a column computed from an expression over existing columns.

Use cases

  • Derive total = price * quantity or margin = revenue - cost.
  • Build a ratio or percentage from two columns.

What it does

Evaluates a column-based arithmetic expression and appends the result as a new column. All original columns are preserved unchanged.

Before
productpricequantity
Widget9.9910
Gadget24.993
Doohickey4.9925
3 rows · 3 cols
Calculated column (expression: price * quantity → total)
After
productpricequantitytotalnew
Widget9.991099.9
Gadget24.99374.97
Doohickey4.9925124.75
3 rows · 4 cols

Configuration

Config keyTypeRequiredDescription
column_namestringYesNew column name
expressionstringYesArithmetic expression, e.g. price * quantity

The editor offers formula templates that fill the expression from your upstream column names.

Generated Python code

df_2 = df_1.eval('total = price * quantity')

Tips & common mistakes

  • Arithmetic expressions only (column names, numbers, + - * /, parentheses). For if/else logic use Conditional column; for ranks/running totals use Window function.
  • Reference columns by their exact name; quote names with spaces per pandas eval rules.

See also