Lab: Using Notebooks
Practice using Databricks notebooks: magic commands for multi-language cells, dbutils for file operations, loading data, and visualizations.
Objectives
- Use magic commands to switch between Python, SQL, and Markdown
- Work with dbutils for file system operations
- Load data from CSV files
- Use display() for rich visualizations
Lab Exercise
See labs/course1/week2/lab_notebooks.py
Key Tasks
- Magic commands — Write Python and SQL cells in the same notebook
- dbutils exploration — List sample datasets, preview file contents
- Load data — Read a CSV file with schema inference
- Visualization — Use display() to create charts from aggregated data
Validation
The lab includes a validate_lab() function that checks:
- Python magic command executed correctly
- DataFrame was loaded with data