ColumnChoice(columns, mode=ColumnMode.KEEP)
Source¶
Columns to keep or to drop, used by Table.choose_columns.
Added in version 0.1.0
Parameters:
-
columns(list[str])The names of the columns. The choice keeps its own copy of the list.
-
mode(ColumnMode, default:ColumnMode.KEEP)KEEPby default, keeping only these columns, in the order of the list, orDROPto remove them.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
EmptyListErrorWhen
columnsis empty withKEEP, which would keep nothing. -
InvalidColumnNameErrorWhen a column name is an empty text.
-
DuplicateColumnErrorWhen a column name appears twice.
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})
sales.choose_columns(ndp.ColumnChoice(columns=["price"]))
# price
# FLOAT64
# 0 120.0
# 1 80.0
# 2 150.0