SortKey(column, order=Order.ASCENDING, missing=MissingPosition.LAST)
Source¶
A column the rows of a Table are sorted by, used by TableSorting.
Added in version 0.1.0
Parameters:
-
column(str)The name of the column.
-
order(Order, default:Order.ASCENDING)Ascending by default.
-
missing(MissingPosition, default:MissingPosition.LAST)Place of the missing values, last by default whatever the order.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidColumnNameErrorWhen
columnis an empty text.
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.sort(ndp.TableSorting(keys=[ndp.SortKey(column="price", order=ndp.Order.DESCENDING)]))
# city price
# TEXT FLOAT64
# 0 Paris 150.0
# 1 Paris 120.0
# 2 Lyon 80.0