Skip to content

Calculation(column, function, result_name=None) Source

A statistic computed on a column of a Table, used by Aggregation.

Added in version 0.1.0

Parameters:

  • column (str)

    The name of the column.

  • function (Statistic)

    A Statistic, such as ndp.Mean() or ndp.Quantile(0.9): see Statistic for every statistic. Missing values are ignored, unless Count is set to include them.

  • result_name (str | None, default: None)

    The name of the result column. When omitted, it is <column>_<function>, such as "price_mean" "price_quantile_90" or "price_count_excluded".

Raises:

Examples:

import numdaplot as ndp

cities = ndp.Array.from_list(["Paris", "Lyon", "Paris"])
prices = ndp.Array.from_list([120.0, 80.0, 150.0])
sales = ndp.Table.from_arrays({"city": cities, "price": prices})
total = ndp.Calculation(column="price", function=ndp.Sum())
highest = ndp.Calculation(column="price", function=ndp.Max(), result_name="highest_price")
sales.aggregate(ndp.Aggregation(calculations=[total, highest]))
#   price_sum highest_price
#     FLOAT64       FLOAT64
# 0     350.0         150.0