Created
January 31, 2015 20:07
-
-
Save linwoodc3/f38fcf91767a68c1de4b to your computer and use it in GitHub Desktop.
From Ben Bengfort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nba | |
# Analyzes the NBA Salary to PER data set | |
# | |
# Author: Benjamin Bengfort <[email protected]> | |
# Created: Sat Sep 20 09:35:11 2014 -0400 | |
# | |
# Copyright (C) 2014 Bengfort.com | |
# For license information, see LICENSE.txt | |
# | |
# ID: nba.py [] [email protected] $ | |
""" | |
Analyzes the NBA Salary to PER data set | |
""" | |
########################################################################## | |
## Imports | |
########################################################################## | |
import os | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
PATH = os.path.abspath('fixtures/nba_players.csv') | |
def read_data(path=PATH): | |
return pd.DataFrame(pd.read_csv(PATH)) | |
def graph_data(path=PATH, xkey='PER', ykey='SALARY'): | |
data = read_data(path) | |
xval = data['PER'] | |
yval = data['SALARY'] | |
fig,axe = plt.subplots() | |
plt.scatter(xval, yval, alpha=0.7) | |
plt.ylim([-10000, data['SALARY'].max()+500000]) | |
plt.ylabel('salary') | |
plt.xlabel('player efficiency rating') | |
plt.title('NBA 2013 Player Efficieny Rating and Salary Correlation') | |
plt.grid(True) | |
plt.show() | |
if __name__ == '__main__': | |
graph_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment