<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Fantasy Football Scoring System
| Stat Category       | Point Value               |
|---------------------|---------------------------|
|Passing Yards        | 1 point for every 25 yards|
|Passing TDs          | 6 points                  |
|Passing Interceptions| -2 points                 |
|Rushing Yeards       | 1 point for every 10 yards|
|Rushing TDs          | 6 points                  |
|Receiving Yards      | 1 point for every 10 yards|
|Receiving TDs        | 6 points                  |
|Fumbles Lost         | -2 points                 |
QB Ratings
Load the data from the from the qb_games.csv file.
NOTE
Step1:  Calculate Fantasy Points
Calculate the fantasy points pased on the table above
Step2:  Get the average QB fantasy points by year
Step3:  Observation
You can trace a sharp improvement in performance over years 1-6 where the fantasy total points increase from a yearly average of 10 to over 15 points.  There is then a plateau through seasons 7 through 14, and a slight uptick at seasons 15-17, but the averages do not break above 20 points on average.
Step4:  Observation
The average passes attempted also match the growth in fantasy points in terms of having their 
sharpest increases in years 1-6, and generally plateauing after that.  One difference is that there really is no general increase in passes attempted years 15-17.
Step5:  Observation
The Passer Rating for QB's shows the same type of improvement for years 1-6 and the same plateau for every year after that.  
Career Means for Key Statistics
Calculate the career means for each of the statistics charted above and use them as filters for evaluating players above and below the mean.
Step6:  Observation
Shifting the data set to only include data for pass attempts above 29 does not greatly change the overall data.
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import matplotlib as mp
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
qb_games = pd.read_csv('qb_games.csv')
qb_games.columns.values
Explanation: Fantasy Football Scoring System
| Stat Category       | Point Value               |
|---------------------|---------------------------|
|Passing Yards        | 1 point for every 25 yards|
|Passing TDs          | 6 points                  |
|Passing Interceptions| -2 points                 |
|Rushing Yeards       | 1 point for every 10 yards|
|Rushing TDs          | 6 points                  |
|Receiving Yards      | 1 point for every 10 yards|
|Receiving TDs        | 6 points                  |
|Fumbles Lost         | -2 points                 |
QB Ratings
Load the data from the from the qb_games.csv file.
NOTE: Games, a count of games for the current season and career_games have been added so that you can differentiate between regular season games (the games used to calculate fantasy stats) and post season or playoff games.  Career Games are a count of how many games a player has played for their career.  It was added as a dimension to consider when measuring player growth, plateau and decline.
End of explanation
qb_games['Fantasy Points'] = (qb_games['Pass Yds']/25) + (6 * qb_games['Pass TD']) - (2 * qb_games['Pass Int']) + (qb_games['Rush Yds'] /10) + (6 * qb_games['Rush TD'])
qb_fantasy = qb_games[['Name','Career Year', 'Year', 'Game Count', 'Career Games', 'Date', 'Pass Att', 'Pass Yds', 'Pass TD', 'Pass Int', 'Pass Rate', 'Rush Att', 'Rush Yds', 'Rush TD', 'Fantasy Points']]
qb_fantasy.head(10)
Explanation: Calculate Fantasy Points
Calculate the fantasy points pased on the table above:
(qb_games['Pass Yds']/25) + (6 * qb_games['Pass TD']) - (2 * qb_games['Pass Int']) + (qb_games['Rush Yds'] /10) + (6 * qb_games['Rush TD'])
Store the data to be used for initial analysis in the  Data Frame qb_fantasy
End of explanation
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
print(len(qb_fantasy))
yearly_fantasy_points = qb_fantasy.groupby(['Career Year'], as_index=False).mean()
yearly_fantasy_points[['Career Year', 'Pass Att', 'Pass Rate', 'Fantasy Points']]
color = ['red']
ax = sns.barplot(yearly_fantasy_points['Career Year'], (yearly_fantasy_points['Fantasy Points'] ), palette=color)
Explanation: Get the average QB fantasy points by year
End of explanation
color = ['blue']
ax = sns.barplot(yearly_fantasy_points['Career Year'], (yearly_fantasy_points['Pass Att'] ), palette=color)
Explanation: Observation
You can trace a sharp improvement in performance over years 1-6 where the fantasy total points increase from a yearly average of 10 to over 15 points.  There is then a plateau through seasons 7 through 14, and a slight uptick at seasons 15-17, but the averages do not break above 20 points on average.
End of explanation
color = ['green']
ax = sns.barplot(yearly_fantasy_points['Career Year'], (yearly_fantasy_points['Pass Rate'] ), palette=color)
Explanation: Observation
The average passes attempted also match the growth in fantasy points in terms of having their 
sharpest increases in years 1-6, and generally plateauing after that.  One difference is that there really is no general increase in passes attempted years 15-17.
End of explanation
qb_means = qb_fantasy[['Pass Att', 'Pass Rate', 'Fantasy Points']].mean()
qb_means
pass_att = qb_means['Pass Att']
qb_upper_pass_att = qb_fantasy.loc[qb_fantasy['Pass Att'] > pass_att]
qb_pass_att_mean = qb_upper_pass_att['Pass Att'].mean()
print('Shifting data to only include pass attempts when greater than %d average pass attempts' %(pass_att))
qb_att = qb_upper_pass_att.groupby(['Career Year'], as_index=False).mean()
color = ['blue']
ax = sns.barplot(qb_att['Career Year'], (qb_att['Pass Att'] ), palette=color)
Explanation: Observation
The Passer Rating for QB's shows the same type of improvement for years 1-6 and the same plateau for every year after that.  
Career Means for Key Statistics
Calculate the career means for each of the statistics charted above and use them as filters for evaluating players above and below the mean.
End of explanation
pass_rate = qb_means['Pass Rate']
qb_upper_pass_rate = qb_fantasy.loc[qb_fantasy['Pass Rate'] > pass_rate]
qb_pass_rate_mean = qb_upper_pass_rate['Pass Rate'].mean()
print('Shifting data to only include pass attempts when greater than %d average pass attempts' %(pass_rate))
qb_rate = qb_upper_pass_rate.groupby(['Career Year'], as_index=False).mean()
color = ['green']
ax = sns.barplot(qb_rate['Career Year'], (qb_rate['Pass Rate'] ), palette=color)
qb_upper_fantasy_rate = qb_fantasy.loc[qb_fantasy['Pass Rate'] > pass_rate]
qb_name = qb_upper_fantasy_rate.groupby(['Name'], as_index=False)
print(len(qb_name))
qb_fantasy_rate_mean = qb_upper_fantasy_rate['Fantasy Points'].mean()
print(qb_fantasy_rate_mean)
qb_rate = qb_upper_fantasy_rate.groupby(['Career Year'], as_index=False).mean()
color = ['red']
ax = sns.barplot(qb_rate['Career Year'], (qb_rate['Fantasy Points'] ), palette=color)
qb_upper_pass_rate = qb_fantasy.loc[qb_fantasy['Pass Rate'] > pass_rate]
qb_fantasy_rate = qb_upper_pass_rate.mean()
print(qb_fantasy_rate['Fantasy Points'])
qb_rate = qb_upper_pass_rate.groupby(['Career Year'], as_index=False).mean()
color = ['green']
ax = sns.barplot(qb_rate['Career Year'], (qb_rate['Fantasy Points'] ), palette=color)
Explanation: Observation
Shifting the data set to only include data for pass attempts above 29 does not greatly change the overall data.
End of explanation
<END_TASK>