<jupyter_start><jupyter_text>Exploration of olympic history data - Download the zip all CSVs from here: [120 years of Olympic history: athletes and results](https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results). - Read the [dataset overview](https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results/home) - Use pandas.ipynb from the videos as a reference - https://github.com/justmarkham/pandas-videos/<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>Load athlete_events.csv into a datatrame called `df`<jupyter_code>df = pd.read_csv('athlete_events.csv')
df.head()
df.describe()<jupyter_output><empty_output><jupyter_text>Youngest and oldest participantsNote that the youngest participant was 10 and the oldest 97 ! Find who they are and what sports they cometed in.  - hint: read about idxmin() function<jupyter_code>df.loc[df.Age.idxmin()]
df.loc[df.Age.idxmax()]<jupyter_output><empty_output><jupyter_text>How many unique athletes are listed in the dataset?<jupyter_code>df.ID.nunique()<jupyter_output><empty_output><jupyter_text>How many unique athletes got any medals?<jupyter_code>df[df.Medal.notnull()].ID.nunique()<jupyter_output><empty_output><jupyter_text>How many medals of each type were awarded?<jupyter_code>df.groupby('Medal').ID.count()<jupyter_output><empty_output><jupyter_text>Waht's the newest olympic sport in this dataset?<jupyter_code>newest_sport = df.groupby('Sport').Year.min()
newest_sport.sort_values(ascending=False).head()<jupyter_output><empty_output><jupyter_text>What sport had the most participants in the latest summer games?<jupyter_code>df[df.Season=='Summer'].Year.max()<jupyter_output><empty_output><jupyter_text>List all the cities that hosted any olympic games more than once<jupyter_code>games_count = df.groupby('City').Year.nunique()
games_count[games_count>=2].sort_values(ascending=False)<jupyter_output><empty_output><jupyter_text>Plot histograms of Age, Height and Weight of athletes<jupyter_code>df.hist(['Age','Height'], bins=30)<jupyter_output><empty_output><jupyter_text>Plot the histograms again, but separately for men and women<jupyter_code>df.Weight.hist()<jupyter_output><empty_output><jupyter_text>Here is an attempt to plot the number of participants as a function of year. What happaned in mid 1990s that makes this graph look so weird? Plot a more useful graph (or several)<jupyter_code>df.groupby(['Year'])['ID'].count().plot()
plt.grid()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11794276875483373, 'fraction_numerical': 0.009280742459396751, 'mean_word_length': 8.109154929577464, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 50, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, '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': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '37044', 'license': 'Apache-2.0', 'n_tokens_mistral': 930, 'n_tokens_neox': 880, 'n_words': 191, 'path': 'ML1/exercises/olympic_history.ipynb', 'repo_name': 'Mosuswalks/AI-with-Python', 'size': '2586'}