1. Introduction to Visualization with Python – Basic and Customized Plotting
Activity 1: Analyzing Different Scenarios and Generating the Appropriate Visualization
Solution
- Download the dataset hosted on the book GitHub repository, and format it as a
pandas
DataFrame:# load necessary modules import pandas as pd import seaborn as sns from numpy import median, mean
- Read the dataset as a
pandas
DataFrame:# download file 'athlete_events.csv' from course GitHub repository: https://github.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/datasets # read the dataset as a pandas DataFrame olympics_df = pd.read_csv('..../Interactive-Data-Visualization-with-Python/datasets/athlete_events.csv') # preview DataFrame olympics_df.head()
The output is as follows:
Figure 1.32: Olympics dataset
- Filter the DataFrame to contain only medal winners of the year 2016:
# filter the DataFrame to contain medal winners only (for non-winners, the Medal feature...