<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 2016 NHL Hockey Data Set - Sasha Kandrach
Step1:  Here's all of our data
Step2:  Here are each of the columns in the data set
Step3:  Let's count how many players are from each country
Step4:  Let's count how many players are from each country
Step5:  And now let's look at the top ten highest birth cities
Step6:  Let's look at how many of those Toronto-born players were drafted before 2006
Step7:  Let's look at how many of those Edmonton-born players were drafted before 2006
Step8:  Let's look at how many of those Minneapolis-born players were drafted before 2006
Step9:  Concussions...that's always a fun topic. Let's look at the players from each country that reported a concussion. We'll start with the United States
Step10:  Hmmm... only two reported concussions in professional hockey?! highly doubtful...let's look at the injuries that were reported as 'Undisclosed' and call them mystery injuries
Step11:  Let's look at Canada's reported concussions
Step12:  Hmmm...not a lot either. Let's look at the "undisclosed" injuries that were reported
Step13:  Switzerland Concussions
Step14:  Switzerland "Undisclosed Injuries"
Step15:  Sweden Concussions
Step16:  Sweden "Undisclosed" Injuries
Step17:  Germany Concussions
Step18:  Germany "Undisclosed" Injuries
Step19:  Czech Republic Concussions
Step20:  Czech Republic "Undisclosed Injuries"
Step21:  Russia Concussions
Step22:  Russia "Undisclosed Injuries"
Step23:  Lithuania Concussions
Step24:  Lithuania "Undisclosed Injuries"
Step25:  Norway Concussions
Step26:  Norway "Undisclosed" Injuries
Step27:  Let's look at how old the players are
Step28:  Young Players (24 years old or younger) for the United States
Step29:  Young Players (24 years old or younger) for Canada
Step30:  Old Players (36 years old or older) for the United States
Step31:  Old Players (36 years old or younger) for Canada
Step32:  Let's examine the correlation between height and weight
Step33:  And a visual of the correlation...nice
Step34:  Let's examine how many lefty's versus righty's (in shooting) each country has
Step35:  Interesting...Canada has significantly more left-handed shooters (280) than right-handed shooters. Meanwhile, the USA is  pretty even with 110 lefty's and 107 righty's.
Step36:  Correlation between Country and Draft Year
<ASSISTANT_TASK:>
Python Code:
import pandas as pd 
import matplotlib.pyplot as plt 
%matplotlib inline
df= pd.read_excel("NHL 2014-15.xls")
!pip install xlrd
df.columns.value_counts()
Explanation: 2016 NHL Hockey Data Set - Sasha Kandrach
End of explanation
  df.head()
Explanation: Here's all of our data:
End of explanation
df.columns
Explanation: Here are each of the columns in the data set:
End of explanation
df['Ctry'].value_counts().head(10)
Explanation: Let's count how many players are from each country:
End of explanation
df['Nat'].value_counts().head(10)
Explanation: Let's count how many players are from each country: they're basically the same but in some cases are slightly different
End of explanation
df['Birth City'].value_counts().head(10)
Explanation: And now let's look at the top ten highest birth cities
End of explanation
df[(df['Birth City'] == 'Toronto') & (df['Draft'] < 2006.0)].head()
Explanation: Let's look at how many of those Toronto-born players were drafted before 2006
End of explanation
df[(df['Birth City'] == 'Edmonton') & (df['Draft'] < 2006.0)].head()
Explanation: Let's look at how many of those Edmonton-born players were drafted before 2006
End of explanation
df[(df['Birth City'] == 'Minneapolis') & (df['Draft'] < 2006.0)].head()
Explanation: Let's look at how many of those Minneapolis-born players were drafted before 2006
End of explanation
usa_concussion = df[(df['Ctry'] == 'USA') & (df['Injury'] == 'Concussion')]
usa_concussion[["First Name", "Last Name"]]
Explanation: Concussions...that's always a fun topic. Let's look at the players from each country that reported a concussion. We'll start with the United States:
End of explanation
usa_mystery_injury = df[(df['Ctry'] == 'USA') & (df['Injury'] == 'Undisclosed')]
usa_mystery_injury[["First Name", "Last Name"]]
us_concussion
Explanation: Hmmm... only two reported concussions in professional hockey?! highly doubtful...let's look at the injuries that were reported as 'Undisclosed' and call them mystery injuries:
End of explanation
can_concussion = df[(df['Ctry'] == 'CAN') & (df['Injury'] == 'Concussion')]
can_concussion[["First Name", "Last Name"]]
Explanation: Let's look at Canada's reported concussions:
End of explanation
can_mystery_injury = df[(df['Ctry'] == 'CAN') & (df['Injury'] == 'Undisclosed')]
can_mystery_injury[["First Name", "Last Name"]]
Explanation: Hmmm...not a lot either. Let's look at the "undisclosed" injuries that were reported:
End of explanation
che_concussion = df[(df['Ctry'] == 'CHE') & (df['Injury'] == 'Concussion')]
che_concussion[["First Name", "Last Name"]]
Explanation: Switzerland Concussions:
End of explanation
che_mystery_injury = df[(df['Ctry'] == 'CHE') & (df['Injury'] == 'Undisclosed')] 
che_mystery_injury[["First Name", "Last Name"]]
Explanation: Switzerland "Undisclosed Injuries"
End of explanation
swe_concussion = df[(df['Ctry'] == 'SWE') & (df['Injury'] == 'Concussion')]
swe_concussion[["First Name", "Last Name"]]
Explanation: Sweden Concussions:
End of explanation
swe_mystery_injury = df[(df['Ctry'] == 'SWE') & (df['Injury'] == 'Undisclosed')]
swe_mystery_injury[["First Name", "Last Name"]]
Explanation: Sweden "Undisclosed" Injuries
End of explanation
deu_concussion = df[(df['Ctry'] == 'DEU') & (df['Injury'] == 'Concussion')]
deu_concussion[["First Name", "Last Name"]]
Explanation: Germany Concussions:
End of explanation
deu_mystery_injury = df[(df['Ctry'] == 'DEU') & (df['Injury'] == 'Undisclosed')]
deu_mystery_injury[["First Name", "Last Name"]]
Explanation: Germany "Undisclosed" Injuries:
End of explanation
cze_concussion= df[(df['Ctry'] == 'CZE') & (df['Injury'] == 'Concussion')]
cze_concussion[["First Name", "Last Name"]]
Explanation: Czech Republic Concussions:
End of explanation
cze_mystery_injury = df[(df['Ctry'] == 'CZE') & (df['Injury'] == 'Undisclosed')]
cze_mystery_injury[["First Name", "Last Name"]]
Explanation: Czech Republic "Undisclosed Injuries"
End of explanation
rus_concussion = df[(df['Ctry'] == 'RUS') & (df['Injury'] == 'Concussion')]
rus_concussion[["First Name", "Last Name"]]
Explanation: Russia Concussions:
End of explanation
rus_mystery_injury = df[(df['Ctry'] == 'RUS') & (df['Injury'] == 'Undisclosed')]
rus_mystery_injury[["First Name", "Last Name"]] 
Explanation: Russia "Undisclosed Injuries"
End of explanation
ltu_concussion = df[(df['Ctry'] == 'LTU') & (df['Injury'] == 'Concussion')]
ltu_concussion[["First Name", "Last Name"]]
Explanation: Lithuania Concussions
End of explanation
ltu_mystery_injury = df[(df['Ctry'] == 'LTU') & (df['Injury'] == 'Undisclosed')]
ltu_mystery_injury[["First Name", "Last Name"]]
Explanation: Lithuania "Undisclosed Injuries"
End of explanation
nor_concussion = df[(df['Ctry'] == 'NOR') & (df['Injury'] == 'Concussion')]
nor_concussion[["First Name", "Last Name"]]
Explanation: Norway Concussions
End of explanation
nor_mystery_injury = df[(df['Ctry'] == 'NOR') & (df['Injury'] == 'Undisclosed')]
nor_mystery_injury[["First Name", "Last Name"]]
df
Explanation: Norway "Undisclosed" Injuries
End of explanation
birthdate = df[df['DOB']].replace("DOB", "")
birthdate
df['birthyear'] = df['DOB'].astype(str).str.split("'").str.get(1).astype(int)
df
Explanation: Let's look at how old the players are:
End of explanation
young_usa_players = df[(df['Ctry'] == 'USA') & (df['birthyear'] >= 94 )]
young_usa_players[["First Name", "Last Name"]]
Explanation: Young Players (24 years old or younger) for the United States:
End of explanation
young_can_players = df[(df['Ctry'] == 'CAN') & (df['birthyear'] >= 94 )]
young_can_players[["First Name", "Last Name"]]
Explanation: Young Players (24 years old or younger) for Canada:
End of explanation
old_usa_players = df[(df['Ctry'] == 'USA') & (df['birthyear'] <= 80 )]
old_usa_players[["First Name", "Last Name"]]
Explanation: Old Players (36 years old or older) for the United States:
End of explanation
old_can_players = df[(df['Ctry'] == 'CAN') & (df['birthyear'] <= 80 )]
old_can_players[["First Name", "Last Name"]]
Explanation: Old Players (36 years old or younger) for Canada:
End of explanation
df['HT'].describe()
df['Wt'].describe()
Explanation: Let's examine the correlation between height and weight
End of explanation
plt.style.use('ggplot')
df.plot(kind='scatter', x='Wt', y='HT')
Explanation: And a visual of the correlation...nice:
End of explanation
df['S'].value_counts()
df.groupby(['Ctry', 'S']).agg(['count'])
Explanation: Let's examine how many lefty's versus righty's (in shooting) each country has:
End of explanation
usa_left_shot = df[(df['Ctry'] == 'USA') & (df['S'] == 'L')]
usa_left_shot[["First Name", "Last Name"]]
can_left_shot = df[(df['Ctry'] == 'CAN') & (df['S'] == 'L')]
can_left_shot[["First Name", "Last Name"]]
usa_right_shot = df[(df['Ctry'] == 'USA') & (df['S'] == 'R')]
usa_right_shot[["First Name", "Last Name"]]
can_right_shot = df[(df['Ctry'] == 'CAN') & (df['S'] == 'R')]
can_right_shot[["First Name", "Last Name"]]
Explanation: Interesting...Canada has significantly more left-handed shooters (280) than right-handed shooters. Meanwhile, the USA is  pretty even with 110 lefty's and 107 righty's.
End of explanation
plt.style.use('seaborn-deep')
df.head(5).plot(kind='bar', x='Ctry', y='Draft')
df
Explanation: Correlation between Country and Draft Year
End of explanation
<END_TASK>