Interactive Table Visualisation¶
In this notebook, you’ll learn how to use UrbanMapper to load a CSV file and visualise it interactively using the TableVisMixin class. This is a great way to explore your urban data dynamically thanks to Skrub table viz that you can see at: https://skrub-data.org/stable/.
Let’s dive in! 🚀
Step 1: Initialising UrbanMapper¶
We’ll start by creating an instance of UrbanMapper. This sets up the environment for loading your CSV data.
import urban_mapper as um
# Initialise UrbanMapper
mapper = um.UrbanMapper()
Step 3: Loading Your CSV Data¶
Now, we’ll load your CSV file using UrbanMapper’s loader. Replace "<path>" with the actual path to your CSV file. We’ll specify longitude and latitude columns to prepare the data for geospatial use. Change appropriately.
# Load CSV data (replace '<path>' with your file path)
csv_loader = mapper.loader.from_huggingface("oscur/taxisvis1M", number_of_rows=1000, streaming=True).with_columns("pickup_latitude", "pickup_longitude")
data = csv_loader.load()
data.head() # Preview the first few rows
Step 4: Displaying the Table Interactively¶
With your data loaded, let’s use TableVisMixin to create an interactive table. This will allow you to sort, filter, and explore the data dynamically. We’ll display the first 10 rows, sorted by longitude.
Click on some features / columns and use the nice interactive viz by Skrub.
# Create an instance of TableVisMixin
vis = mapper.table_vis.interactive_display(
dataframe=data,
n_rows=10,
title="Interactive Urban Data Report",
verbose=1
)
vis
Wrapping Up¶
That’s it! 🎈 You’ve successfully loaded your CSV data with UrbanMapper and visualised it interactively using TableVisMixin. This interactive display makes it easy to explore your dataset. Feel free to tweak the n_rows, order_by, or other parameters to customise the view!