Back to bricks list
Introduction Version

# Table column operations

TRANSFORMER
Typing name :  TASK.gws_core.TableColumnOperations Brick :  gws_core

Operations on columns for a table

This task allows you to do mathematical operation on a Table column.

It works with the column names, supports basic operations, comparator, parenthesis and some math functions.

## Examples

Let's say you have this `Table` with the column A, B, C, D

A B C D
1 10 11 -9
2 8 10 -6
3 6 9 -3

Here is few example that you can write in the `operations` config.

• Addition : `A + B + C`
• Constant : `A + 10`
• Subtraction : `A - C`
• Multiplication : `A * C`
• Division : `A / C`
• Exponentiation : `A ** C`
• Modulus : ` A % C`
• Floor division : ` A // C`
• Advanced exemple : `(A + B) / (C * D)`

## Comparaison

This task support comparaison, it will return the string `True` or `False`.

Comparaison operators : `==`, `!=`, `>`, `<`, `>=` and `<=`

## Math functions

This task supports basic math functions : `sin`, `cos`, `exp`, `log`, `expm1`, `log1p`, `sqrt`, `sinh`, `cosh`, `tanh`, `arcsin`, `arccos`, `arctan`, `arccosh`, `arcsinh`, `arctanh`, `abs`, `arctan2` and `log10`.

Example : `log(A)`

## Define column names

You can define a custom column name in the `operations`. Example : `E = A + B`, this will set the result in the `E` columns.

## Multiple operation

Multiple operation are possible but it requires an assignment to a new columns.

For exemple, if you want to create 2 new calculated columns you could do write 2 operation (in 2 different lines) :

``````E = A + B
F = C - D
``````

The result of the previous operation can also be use for the next operation (here we use the new column `E` to calculate `F`) :

``````E = A + B
F = E - D
``````

This task uses the eval function of python dataframe. To see all the possibility, check the following link : https://pandas.pydata.org/pandas-docs/stable/user_guide/enhancingperf.html#expression-evaluation-via-eval

### Input

Table
2d excel like table

### Output

Table
2d excel like table

### Configuration

operations

Type : `list`
Type : `bool`