<jupyter_start><jupyter_text>Activity<jupyter_code>import pandas as pd
import seaborn as sns
from numpy import median, mean

# download file 'athlete_events.csv' from course github repository: https://github.com/TrainingByPackt/Interactive-Data-Visualization-with-Python
# read the dataset as a pandas dataframe
olympics_df = pd.read_csv('https://raw.githubusercontent.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/master/datasets/athlete_events.csv')

# preview dataframe
olympics_df.head()

# filter the dataframe to contain medal winners only (for non-winners, the Medal feature is NaN)
# note use of the inplace parameter
olympics_winners = olympics_df.dropna(subset=['Medal'])
olympics_winners.head()

# print records for each value of the feature 'Sport'
olympics_winners_2016 = olympics_winners[(olympics_winners.Year == 2016)]
olympics_winners_2016.Sport.value_counts()

# list the top 5 sports
top_sports = ['Athletics', 'Swimming', 'Rowing', 'Football', 'Hockey']

# subset the dataframe to include data from the top sports
olympics_top_sports_winners_2016 = olympics_winners_2016[(olympics_winners_2016.Sport.isin(top_sports))]
olympics_top_sports_winners_2016.head()

# generate bar plot indicating count of medals awarded in each of the top sports
g = sns.catplot('Sport', data=olympics_top_sports_winners_2016, kind="count", aspect=1.5)

sns.distplot(olympics_top_sports_winners_2016.Age, kde=False)
g = sns.catplot('Team', data=olympics_top_sports_winners_2016, kind="count", aspect=3)
g.set_xticklabels(rotation=90)

sns.set(style="whitegrid")
sns.barplot(x="Sport", y="Weight", data=olympics_top_sports_winners_2016, estimator=mean, hue='Sex')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1054481546572935, 'fraction_numerical': 0.029291154071470416, 'mean_word_length': 7.714285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '468932', 'license': 'MIT', 'n_tokens_mistral': 657, 'n_tokens_neox': 587, 'n_words': 127, 'path': 'Lesson01/Activity01.ipynb', 'repo_name': 'TrainingByPackt/Interactive-Data-Visualization-with-Python', 'size': '1707'}