logo


altair


<p>There are many visualisation libraries in python out there and <a href="https://altair-viz.github.io/gallery/index.html">altair</a> offers some original features. It offers a wide variety of charts, a grammar-like api, loads of interactivity features and the option of exporting directly to the browser.</p>


1 - Introduction
2 - Recipe
3 - Properties
4 - Line Chart
5 - Types
6 - Operators
7 - Json
8 - Downsides

For this video you'll need to install the following dependencies;

python -m pip install jupyterlab pandas altair

You'll also need the dataset, it can be fetched here or downloaded via;

wget https://calmcode.io/datasets/birthdays.csv

The python code in the beginning of this notebook is;

import pathlib 
import pandas as pd
import altair as alt

df = pd.read_csv("content/data/birthdays.csv")

def clean_dataset(dataf):
    return (dataf
            .assign(date = lambda d: pd.to_datetime(d['date']))
            .assign(yday = lambda d: d['date'].dt.dayofyear)
            .drop(columns=['Unnamed: 0'])
            .groupby(['date', 'wday', 'yday'])
            .agg(births = ('births', 'sum'), month=('month', 'first'))
            .reset_index())

plot_df = df.pipe(clean_dataset)