API Reference
This page is auto-generated from Python docstrings.
datafun
Datafun - data fundamentals course package.
app
src/datafun/app.py - Project script.
Author: Denise Case Date: 2026-08
HOW TO RUN THIS FILE:
From the VS Code menu (with only this project open in VS Code), click "Terminal" / New Terminal to open an integrated Terminal in the root project folder. Paste the following command and press ENTER or RETURN to run this file as a script:
uv run python -m datafun.app
DOMAIN:
A small business with regions, stores, and employees.
The data is stored in three related CSV files:
- one row per region
- one row per store
- one row per employee
One region can have many stores. One store can have many employees.
EXPLORE:
Sometimes the information needed for an analysis is stored in more than one related table.
SQL is especially useful when tables share keys and we want to analyze information across them.
A simple Python and SQL process is:
- LOAD the related tables.
- INSPECT the grain and keys.
- CREATE a SQLite database.
- LOAD the tables into SQLite.
- QUERY across related tables with SQL.
- VISUALIZE the query result with Python.
- SUMMARIZE what you found.
- DISPLAY the visualization.
DESIGN:
Use this file to declare the data-specific choices and the reasoning behind them, then orchestrate the work.
SQLite comes from the Python Standard Library. Pandas loads tabular data into SQLite and returns SQL query results as DataFrames. Reusable visualization functions come from eda-vizkit.
The SQL stays here because the query is an analytical decision specific to this project.
main
main() -> None
Entry point when running this file as a Python script.
This is where the instructions begin.
Arguments: None. Returns: None.
Source code in src/datafun/app.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
notebook
src/datafun/notebook.py - Reactive SQL explorer.
Author: Denise Case Date: 2026-08
REQUIREMENTS:
- Add marimo to notebooks in pyproject.toml.
- Install the required dependencies using uv sync.
RUN:
Open this project folder in VS Code. Open an integrated Terminal in the root project folder and paste the following command.
uv run marimo run src/datafun/notebook.py
EDIT:
uv run marimo edit src/datafun/notebook.py
DOMAIN:
A small business with regions, stores, and employees.
The data is stored in three related tables.
One region can have many stores. One store can have many employees.
EXPLORE:
Use the dropdown to select a region.
Python passes the selected value to SQL as a bound parameter. SQL joins the related tables and returns one row per store.
The SQL query result is returned as a pandas DataFrame. Python then visualizes the result.
Change the selected region and Marimo automatically updates the query result and chart.
NO LOGGING:
In this notebook, we do not configure logging because a browser-based WASM app has no persistent Python server to store log files.
FIRST: IMPORT AND APP SETUP (ALWAYS)
THEN: PLAN CELLS FIRST - I want these cells:
- opening Markdown
- load (related) data
- create database for SQL
- choose a selected region
- run a parameterized SQL query
- show selection
- show df table and chart result
Note: No need to call @app.cell functions in marimo, it triggers them automagically. I could name them all "", but I choose to give them internal function names starting with "" so I can organize my thinking and my app.
load_csv_for_notebook
load_csv_for_notebook(
*, local_path: Path, public_path: Path
) -> pd.DataFrame
Load a CSV locally or in a deployed WASM app.
Source code in src/datafun/notebook.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |