Shimoku docs
Search…
⌃K

Table

Resources on how to build a table with your data, and personalize it.

The method to use

The method is shimoku.plt.table()
It must contain the following input variables:
data: Union[str, DataFrame, List[Dict]]
menu_path: str
order: int
horizontal_scrolling: bool
overwrite: bool
And accepts the following input variables as optional:
title: Optional[str] = None
filter_columns: Optional[List[str]] = None
sort_table_by_cols: Optional[List] = None

Examples

1. Default configuration

This code generates a table with two filters:
data_ = [
{'date': dt.date(2021, 1, 1), 'x': 5, 'y': 5, 'filtA': 'A', 'filtB': 'B'},
{'date': dt.date(2021, 1, 2), 'x': 6, 'y': 5, 'filtA': 'B', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 3), 'x': 4, 'y': 5, 'filtA': 'C', 'filtB': 'W'},
{'date': dt.date(2021, 1, 4), 'x': 7, 'y': 5, 'filtA': 'B', 'filtB': 'T'},
{'date': dt.date(2021, 1, 5), 'x': 3, 'y': 5, 'filtA': 'A', 'filtB': 'Z'},
]
shimoku.plt.table(
data=data_,
menu_path='test/table-1',
order=0,
)
The result is:
The table is in the default configuration, it may be needed to scroll down the page.

2. Modifying the data frame, order of entries and title:

You can personalize the table by changing the column names in the input data frame, defining by which columns the table can be sorted and adding a title:
data_ = [
{'date': dt.date(2021, 1, 1), 'Bus1': 5, 'Bus2': 5, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 2), 'Bus1': 6, 'Bus2': 7, 'filtA': 'B', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 3), 'Bus1': 4, 'Bus2': 5, 'filtA': 'A', 'filtB': 'W'},
{'date': dt.date(2021, 1, 4), 'Bus1': 7, 'Bus2': 8, 'filtA': 'B', 'filtB': 'W'},
{'date': dt.date(2021, 1, 5), 'Bus1': 3, 'Bus2': 5, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 6), 'Bus1': 5, 'Bus2': 5, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 7), 'Bus1': 6, 'Bus2': 7, 'filtA': 'B', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 8), 'Bus1': 4, 'Bus2': 5, 'filtA': 'A', 'filtB': 'W'},
{'date': dt.date(2021, 1, 9), 'Bus1': 7, 'Bus2': 5, 'filtA': 'B', 'filtB': 'W'},
{'date': dt.date(2021, 1, 10), 'Bus1': 3, 'Bus2': 7, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 11), 'Bus1': 5, 'Bus2': 5, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 12), 'Bus1': 6, 'Bus2': 5, 'filtA': 'B', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 13), 'Bus1': 4, 'Bus2': 8, 'filtA': 'A', 'filtB': 'W'},
{'date': dt.date(2021, 1, 14), 'Bus1': 7, 'Bus2': 5, 'filtA': 'B', 'filtB': 'W'},
{'date': dt.date(2021, 1, 15), 'Bus1': 3, 'Bus2': 5, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 16), 'Bus1': 5, 'Bus2': 8, 'filtA': 'A', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 17), 'Bus1': 6, 'Bus2': 5, 'filtA': 'B', 'filtB': 'Z'},
{'date': dt.date(2021, 1, 18), 'Bus1': 4, 'Bus2': 7, 'filtA': 'A', 'filtB': 'W'},
{'date': dt.date(2021, 1, 19), 'Bus1': 7, 'Bus2': 5, 'filtA': 'B', 'filtB': 'W'},
{'date': dt.date(2021, 1, 20), 'Bus1': 3, 'Bus2': 7, 'filtA': 'A', 'filtB': 'Z'},
]
shimoku.plt.table(
data=data_,
menu_path='test/table-3',
order=0,
title="Amount of Buses in daily routes",
sort_table_by_col={'date': 'asc'},
)
After executing the code shown above you will get:
Table with more data and title.

Behaviour

Important behaviour considerations to have in mind.

Pagination

If you build a table with more than 10 rows, more pages are added and to show the entire table just click the > symbol:
Table with pagination activated

Download data in .csv format

You can retrieve the data from the table in .csv format by clicking the download button showed bellow:
Table with the option to download the data
When clicked the file is stored with an automatic name generated with the name of the table:
Result from a table named "test table"
Contents of the generated file
This feature is enabled by default, but can be easily disabled by changing the parameter downloadable_to_csv to False:
shimoku.plt.table(
data=data,
order=0,
title="No csv button",
downloadable_to_csv=False,
)
Changing menu_path The menu_path can be modified.
It is possible to use any number of rows.