<jupyter_start><jupyter_text>Summer Olympics Data Analysis Assignment<jupyter_code>import sys

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('/content/drive/MyDrive/py_file/summer.csv')
df.head()

df["Year"].head()
df.isnull().sum()
df['Athlete'].unique()<jupyter_output><empty_output><jupyter_text>1. In how many cities Summer Olympics is held so far?<jupyter_code>print(len(df['City'].unique()))<jupyter_output>22<jupyter_text>2. Which sport is having most number of Gold Medals so far? (Top 5)<jupyter_code>data=[]
for sport in sportInOlympics['Sport'].unique():
    data.append([sport,len(sportInOlympics[sportInOlympics['Sport']==sport])])
data=pd.DataFrame(data, columns=['Sport','No. of gold medals']) 
top5=data.sort_values(by='No. of gold medals', ascending=False).head()
print(top5)

top5.plot(x='Sport',y='No. of gold medals',kind='bar')<jupyter_output>Sport  No. of gold medals
0     Aquatics                1421
1    Athletics                1214
17      Rowing                 890
4   Gymnastics                 820
3      Fencing                 552<jupyter_text>3. Which sport is having most number of medals so far? (Top 5)<jupyter_code>data=[]
for Sport in df["Sport"].unique():
    data.append([Sport , len(df[df["Sport"] == Sport])])
top5 = pd.DataFrame(data,columns = ['Sport','Medal']).sort_values(by='Medal', ascending=False).head(5)
print(top5)
print()
top5.plot(x = 'Sport', y = 'Medal', kind = 'bar')<jupyter_output>Sport  Medal
0     Aquatics   4170
1    Athletics   3638
17      Rowing   2667
4   Gymnastics   2307
3      Fencing   1613<jupyter_text>4. Which player has won most number of medals? (Top 5)<jupyter_code>data=[]
for sport in df['Athlete'].unique():
    data.append([sport,len(df[df['Athlete']==sport])])
data = pd.DataFrame(data, columns=['Athlete','No. of medals']) 
top5 = data.sort_values(by='No. of medals', ascending=False).head()
print(top5)

top5.plot(x='Athlete',y='No. of medals',kind='bar')<jupyter_output>Athlete  No. of medals
18640       <NAME>             22
7197       <NAME>             18
9948     <NAME>             15
6591           <NAME>             13
5103   MANGIAROTTI, Edoardo             13<jupyter_text>5. Which player has won most number Gold Medals of medals? (Top 5)<jupyter_code>goldmedals = df[ (df.Medal == 'Gold')]
data=[]
for sport in goldmedals['Athlete'].unique():
    data.append([sport,len(goldmedals[goldmedals['Athlete']==sport])])
data=pd.DataFrame(data, columns=['Athlete','No. of gold medals']) 
top5 = data.sort_values(by='No. of gold medals', ascending=False).head()
print(top5)

top5.plot(x='Athlete',y='No. of gold medals',kind='bar')<jupyter_output>Athlete  No. of gold medals
6851   <NAME>                  18
3320       <NAME>                   9
2714  <NAME>                   9
4630       <NAME>                   9
907       NUR<NAME>                   9<jupyter_text>6. In which year India won first Gold Medal in Summer Olympics?<jupyter_code>India = df[(df.Country=="IND") & (df.Medal == 'Gold')]
India.head(1)<jupyter_output><empty_output><jupyter_text>7. Which event is most popular in terms on number of players? (Top 5)<jupyter_code>data=[]
for sport in df['Event'].unique():
    data.append([sport,len(df[df['Event']==sport])])
data=pd.DataFrame(data, columns=['Event','No. of players']) 
top5 = data.sort_values(by='No. of players', ascending=False).head()
print(top5)
top5.plot(x='Event',y='No. of players',kind='bar')<jupyter_output>Event  No. of players
80           Football            1497
176            Hockey            1422
138  Team Competition            1147
327        Basketball            1012
337          Handball             973<jupyter_text>8. Which sport is having most female Gold Medalists? (Top 5)<jupyter_code>female = df[(df.Gender == 'Women') & (df.Medal == 'Gold')]
data=[]
for sport in female['Sport'].unique():
    data.append([sport,len(female[female['Sport']==sport])])
data=pd.DataFrame(data, columns=['Sport','No. of female gold medalists']) 
top5 = data.sort_values(by='No. of female gold medalists', ascending=False).head()
print(top5)
top5.plot(x='Sport',y='No. of female gold medalists',kind='bar')<jupyter_output>Sport  No. of female gold medalists
4     Aquatics                           589
7    Athletics                           389
8   Gymnastics                           268
14      Rowing                           217
11  Volleyball                           166
{'fraction_non_alphanumeric': 0.14173581520520295, 'fraction_numerical': 0.04395604395604396, 'mean_word_length': 3.164332399626517, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '520782', 'license': 'MIT', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1495, 'n_words': 361, 'path': 'Summer_Olympics_Data_Analysis.ipynb', 'repo_name': 'MrElectrouino/Summer-Olympics-Data-Analysis', 'size': '4528'}