Order

Order#

Since itables>=1.3.0, the interactive datatable shows the rows in the same order as the original dataframe:

import pandas as pd

import itables

itables.init_notebook_mode()

for name, test_df in itables.sample_dfs.get_dict_of_test_dfs().items():
    if "sorted" in name:
        itables.show(test_df, caption=name.replace("_", " ").title())
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)

You can also set an explicit order argument:

sorted_df = pd.DataFrame({"i": [1, 2], "a": [2, 1]}).set_index(["i"])
itables.show(sorted_df, order=[[1, "asc"]])
Loading ITables v2.4.0rc1 from the init_notebook_mode cell... (need help?)