Interactive Table VIS Mixin¶
Optional module
Install the interactive_table_vis extra before using these helpers:
pip install urban-mapper-community[interactive_table_vis]uv add urban-mapper-community --group interactive_table_vis
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
¶
Classes¶
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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
Functions¶
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
... )