Loading...

vastorbit.core.tablesample.base.TableSample.sort

TableSample.sort(column: str, desc: bool = False) TableSample

Sorts the TableSample using the input column.

Parameters:
  • column (str, optional) – Column used to sort the data.

  • desc (bool, optional) – If set to True, the result is sorted in descending order.

Returns:

self.

Return type:

TableSample

Examples

Let’s import the TableSample object:

from vastorbit import TableSample

Let’s build an example object.

# dict with all the data.
d = {
    "customer_ID": [0, 1, 2, 3],
    "age": [40, 30, 22, 55],
    "name": ['Roger', 'Maria', 'Alisia', 'Costi'],
}

# creating the object.
tb = TableSample(d)
customer_IDagename
1040Roger
2130Maria
3222Alisia
4355Costi
Rows: 1-4 | Columns: 3

Let’s use the function. We will sort in descending order using the “age” column.

tb.sort("age", desc = True)
customer_IDagename
1355Costi
2040Roger
3130Maria
4222Alisia
Rows: 1-4 | Columns: 3

See also

TableSample.merge() : Merges the input TableSample to a target TableSample.