Interactive Table VIS Mixin¶
What is Interactive Table VIS Mixin?
The Interactive Table VIS
mixin is responsible to allow the user to vis. and interact with any dataset of interest
within your Jupyter Notebook much better than Pandas Dataframe visualisation. Showing off statistics on top
of each of your dataset's attributes, etc.
A mixin, in this very instance, is nothing more than a class that connects external libraries for their use
directly adapted towards the UrbanMapper
workflow.
Documentation Under Alpha Construction
This documentation is in its early stages and still being developed. The API may therefore change, and some parts might be incomplete or inaccurate.
Use at your own risk, and please report anything that seems incorrect
/ outdated
you find.
interactive_table_vis
¶
TableVisMixin
¶
Mixin for creating interactive data table visualisations in notebooks.
This mixin provides methods for displaying dataframes as interactive tables with filtering and sorting capabilities. It enhances the data exploration experience in Jupyter notebooks by offering richer visualisations compared to standard DataFrame displays.
All this thanks to Skrub's TableReport
class. Find out more about Skrub, via their official doc.
Examples:
>>> from urban_mapper import UrbanMapper
>>> import geopandas as gpd
>>>
>>> # Initialise UrbanMapper
>>> mapper = UrbanMapper()
>>>
>>> # Load sample data
>>> data = gpd.read_file("nyc_taxi_trips.geojson")
>>>
>>> # Display as an interactive table
>>> mapper.table_vis.interactive_display(
... dataframe=data,
... n_rows=15,
... order_by="trip_distance",
... title="NYC Taxi Trips"
... )
Source code in src/urban_mapper/mixins/interactive_table_vis.py
interactive_display(dataframe, n_rows=10, order_by=None, title='Table Report', column_filters=None, verbose=1)
¶
Display a dataframe
as an interactive HTML
table with sorting and filtering capabilities.
This method generates an enhanced table visualisation, enabling users to explore data more effectively than with standard DataFrame displays. It supports sorting by columns, applying filters, and customising the number of rows displayed.
Find out more about the TableReport
class in the Skrub documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe
|
Union[DataFrame, GeoDataFrame]
|
The dataframe to display. |
required |
n_rows
|
int
|
Number of rows to show in the table. Defaults to 10. |
10
|
order_by
|
Optional[Union[str, List[str]]]
|
Column(s) to sort the data by. Defaults to None. |
None
|
title
|
Optional[str]
|
Title to display above the table. Defaults to "Table Report". |
'Table Report'
|
column_filters
|
Optional[Dict[str, Dict[str, Union[str, List[str]]]]]
|
Filters to apply to specific columns. Format: {column_name: {filter_type: filter_value}}, e.g., {"fare_amount": {"greater_than": 50.0}}. Defaults to None. |
None
|
verbose
|
int
|
Verbosity level for report generation. Defaults to 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
Displays the table directly in the notebook. |
Examples:
>>> # Basic display with default settings
>>> mapper.table_vis.interactive_display(dataframe=data)
>>>
>>> # Advanced display with sorting and filtering
>>> mapper.table_vis.interactive_display(
... dataframe=taxi_data,
... n_rows=20,
... order_by=["trip_distance", "fare_amount"],
... title="High-Value Taxi Trips",
... column_filters={
... "payment_type": {"equals": "credit card"},
... "fare_amount": {"greater_than": 50.0}
... },
... verbose=2
... )