{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exercise 2.1: Plotting with Palmer penguins\n", "\n", "[Data set download](https://s3.amazonaws.com/bebi103.caltech.edu/data/penguins_subset.csv)\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "In a previous exercise, you tidied a subset of the [Palmer penguins data set](https://s3.amazonaws.com/bebi103.caltech.edu/data/penguins_subset.csv). To do that, you did the following." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv('../data/penguins_subset.csv', header=[0, 1])\n", "\n", "df_tidy = df.stack(\n", " level=0\n", ").sort_index(\n", " level=1\n", ").reset_index(\n", " level=1\n", ").rename(\n", " columns={\"level_1\": \"species\"}\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, use that tidied data set to make a scatter plot of bill length versus flipper length with the glyphs colored by species. " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 4 }