Deduplication(columns=None, keep=Keep.FIRST)
Source¶
Which rows count as duplicates and which one is kept, used by Table.drop_duplicates.
Two missing values are equal when comparing rows.
Added in version 0.1.0
Parameters:
-
columns(list[str] | None, default:None)The names of the columns compared, every column when omitted. The deduplication keeps its own copy of the list.
-
keep(Keep, default:Keep.FIRST)The row kept in each group of duplicates, the first one by default.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
EmptyListErrorWhen
columnsis an empty list. -
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.drop_duplicates(ndp.Deduplication(columns=["city"]))
# city price
# TEXT FLOAT64
# 0 Paris 120.0
# 1 Lyon 80.0