Math

Calculate one or more new columns using math functions.

Parameters

NameTypeDescriptionIs Optional

math_ops

math_list

List of math operations to generate new columns. For example, ["AGE_COLUMN + 5", "WEIGHT_COLUMN / 100"]

names

value_list

To alias the new columns, provide a list of column names matching the number of math operations.

True

Example

Pull a source Dataset and preview it:

ds = rasgo.get.dataset(id)
print(ds.preview())
SALESAMOUNTTAXAMTDUEDATE

0

3578.27

286.262

2011-01-10 00:00:00

1

3399.99

271.999

2011-01-10 00:00:00

2

3399.99

271.999

2011-01-10 00:00:00

3

699.098

55.9279

2011-01-10 00:00:00

4

3399.99

271.999

2011-01-10 00:00:00

5

3578.27

286.262

2011-01-11 00:00:00

6

3578.27

286.262

2011-01-11 00:00:00

7

3374.99

269.999

2011-01-11 00:00:00

8

3399.99

271.999

2011-01-11 00:00:00

9

3578.27

286.262

2011-01-12 00:00:00

Transform the Dataset and preview the result:

ds2 = ds.math(
    math_ops=['SALESAMOUNT * 10', 'SALESAMOUNT - TAXAMT'],
    names=['SALES10', 'SALESNET'])

ds2.preview()
SALESAMOUNTTAXAMTDUEDATESALES10SALESNET

0

3578.27

286.262

2011-01-10 00:00:00

35782.7

3292.01

1

3399.99

271.999

2011-01-10 00:00:00

33999.9

3127.99

2

3399.99

271.999

2011-01-10 00:00:00

33999.9

3127.99

3

699.098

55.9279

2011-01-10 00:00:00

6990.98

643.17

4

3399.99

271.999

2011-01-10 00:00:00

33999.9

3127.99

5

3578.27

286.262

2011-01-11 00:00:00

35782.7

3292.01

6

3578.27

286.262

2011-01-11 00:00:00

35782.7

3292.01

7

3374.99

269.999

2011-01-11 00:00:00

33749.9

3104.99

8

3399.99

271.999

2011-01-11 00:00:00

33999.9

3127.99

9

3578.27

286.262

2011-01-12 00:00:00

35782.7

3292.01

Source Code

Last updated