{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualization in the data science workflow\n", "> Often visualization is taught in isolation, with best practices only discussed in a general way. In reality, you will need to bend the rules for different scenarios. From messy exploratory visualizations to polishing the font sizes of your final product; in this chapter, we dive into how to optimize your visualizations at each step of a data science workflow. This is the Summary of lecture \"Improving Your Data Visualizations in Python\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Visualization]\n", "- image: images/markets_scatter.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "\n", "plt.rcParams['figure.figsize'] = (10, 5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## First explorations\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Looking at the farmers market data\n", "Loaded is a new dataset, `markets`. Each row of this DataFrame belongs to an individual farmers market in the continental United States with various information about the market contained in the columns. In this exercise, explore the columns of the data to get familiar with them for future analysis and plotting.\n", "\n", "As a first step, print out the first three lines of `markets` to get an idea of what type of data the columns encode. Then look at the summary descriptions of all of the columns. Since there are so many columns in the DataFrame, you'll want to turn the results 'sideways' by transposing the output to avoid cutting off rows." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | name | \n", "city | \n", "county | \n", "state | \n", "lat | \n", "lon | \n", "months_open | \n", "Bakedgoods | \n", "Beans | \n", "Cheese | \n", "... | \n", "Prepared | \n", "Seafood | \n", "Soap | \n", "Tofu | \n", "Trees | \n", "Vegetables | \n", "WildHarvested | \n", "Wine | \n", "num_items_sold | \n", "state_pop | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "Island Market | \n", "Key Largo | \n", "Monroe | \n", "Florida | \n", "-80.427218 | \n", "25.109214 | \n", "6 | \n", "1 | \n", "1 | \n", "1 | \n", "... | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "18 | \n", "19893297.0 | \n", "
1 | \n", "COFFO Harvest Farmers' Market | \n", "Florida City | \n", "Miami-Dade | \n", "Florida | \n", "-80.482299 | \n", "25.449850 | \n", "12 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "7 | \n", "19893297.0 | \n", "
2 | \n", "COFFO Harvest Farmers' Market | \n", "Homestead | \n", "Miami-Dade | \n", "Florida | \n", "-80.483400 | \n", "25.463500 | \n", "12 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "7 | \n", "19893297.0 | \n", "
3 | \n", "Verde Gardens Farmers Market | \n", "Homestead | \n", "Miami-Dade | \n", "Florida | \n", "-80.395607 | \n", "25.506727 | \n", "12 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "5 | \n", "19893297.0 | \n", "
4 | \n", "Verde Community Farm and Market | \n", "Homestead | \n", "Miami-Dade | \n", "Florida | \n", "-80.395607 | \n", "25.506727 | \n", "9 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "5 | \n", "19893297.0 | \n", "
5 rows × 38 columns
\n", "