NewColumn(name, values, on_conflict=Conflict.ERROR)
Source¶
A column to add to a Table, used by Table.add_column.
Added in version 0.1.0
Parameters:
-
name(str)The name of the column, a non-empty text.
-
values(Array)A one-dimensional Array with one value per row of the Table.
-
on_conflict(Conflict, default:Conflict.ERROR)ERRORby default, refusing a name that already exists, orREPLACEto replace the existing column, at its place.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidColumnNameErrorWhen
nameis empty.
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})
taxed_prices = sales.column("price") * 1.2
sales.add_column(ndp.NewColumn(name="taxed_price", values=taxed_prices))
# city price taxed_price
# TEXT FLOAT64 FLOAT64
# 0 Paris 120.0 144.0
# 1 Lyon 80.0 96.0
# 2 Paris 150.0 180.0