How to Sort the Tabular Data in Python
The Python "tabular" library provides a rich suite of features for manipulating data stored in tables, similar to those in a spreadsheet application. Readymade sorting and filtering functions make it vastly more powerful than an ordinary array, but they aren't the most obvious functions to use.
Instructions
-
-
1
Import the tabular library by typing the following into your Python debugger:
import tabular as tb
-
2
Create a fast table by typing the following into your Python debugger:
Records = [(1,1)(1,2),(2,1),(2,2)]
X = tb.tabarray(records = Records, names=['Column 1', 'Column 2'])This creates a simple table with two rows and two columns. The columns are named, appropriately enough, "Column 1" and "Column 2."
-
-
3
Sort the table by typing the following:
X.sort(order=['Column 1', 'Column 2'])
XThe "order" command tells Python which columns you want to sort by. You can specify as many columns as you like, and they will be sorted in that order.
-
1