# Example Notebook¶

## Formatted Text and Equations¶

In Markdown cells (like this one), you can write plain text or add formatting and other elements with Markdown. These include headers, bold text, italic text, hyperlinks, equations $A=\pi r^2$, inline code `print('Hello world!')`, bulleted lists, and more.

### You can use headings of various sizes¶

#### Slightly smaller¶

##### Even smaller!¶

Here is a bulleted list.

- One item
- Another item
  - A sub-item
- More stuff

Here is a numbered list.

1. Cat
2. Dog
3. Hamster

## Code¶

In Code cells (like the one below) you can execute snippets of code and display the output.

In [1]:

    print('Hello world!')

    Hello world!

## Example: Cars Data¶

Import the Seaborn library and load the example dataset of miles per gallon and other metrics for various cars:

In [2]:

    # Seaborn library for statistical data visualization
    import seaborn as sns

    # Load dataset from Seaborn
    mpg = sns.load_dataset('mpg')

    # Display the first 5 rows
    mpg.head()

Out[2]:

| mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
0 | 18.0 | 8 | 307.0 | 130.0 | 3504 | 12.0 | 70 | usa | chevrolet chevelle malibu
1 | 15.0 | 8 | 350.0 | 165.0 | 3693 | 11.5 | 70 | usa | buick skylark 320
2 | 18.0 | 8 | 318.0 | 150.0 | 3436 | 11.0 | 70 | usa | plymouth satellite
3 | 16.0 | 8 | 304.0 | 150.0 | 3433 | 12.0 | 70 | usa | amc rebel sst
4 | 17.0 | 8 | 302.0 | 140.0 | 3449 | 10.5 | 70 | usa | ford torino

Create a bubble plot of miles per gallon vs. horsepower:

In [3]:

    sns.relplot(data=mpg, x='horsepower', y='mpg', hue='origin', size='weight',
                sizes=(40, 400), alpha=0.5, palette="muted", height=5);

## Example: Fisher's Iris Data¶

In [4]:

    iris = sns.load_dataset('iris')
    iris.head()

Out[4]:

| sepal_length | sepal_width | petal_length | petal_width | species
--- | --- | --- | --- | --- | ---
0 | 5.1 | 3.5 | 1.4 | 0.2 | setosa
1 | 4.9 | 3.0 | 1.4 | 0.2 | setosa
2 | 4.7 | 3.2 | 1.3 | 0.2 | setosa
3 | 4.6 | 3.1 | 1.5 | 0.2 | setosa
4 | 5.0 | 3.6 | 1.4 | 0.2 | setosa

Plot pairwise relationships:

In [5]:

    sns.pairplot(data=iris, hue='species');

Back to home