Skip to content

TableApplication(function, columns) Source

A function applied to each value of columns of a Table, used by Table.apply.

Each column is replaced at its place, under its name. A missing value stays missing, and an integer or boolean column keeps its type when a ValueMapping gives it missing values.

Added in version 0.2.0

Parameters:

Raises:

Examples:

import numdaplot as ndp

first_answers = ndp.Array.from_list([1, 7, 2])
second_answers = ndp.Array.from_list([9, 3, 1])
survey = ndp.Table.from_arrays({"q1": first_answers, "q2": second_answers})
unknown_answers = [ndp.ValueChange(7, None), ndp.ValueChange(9, None)]
mapping = ndp.ValueMapping(changes=unknown_answers, others=ndp.Unmatched.KEEP)
survey.apply(ndp.TableApplication(function=mapping, columns=["q1", "q2"]))
#      q1    q2
#   INT64 INT64
# 0     1  <NA>
# 1  <NA>     3
# 2     2     1