Created
August 21, 2014 17:53
-
-
Save bbengfort/eefc7fe5b66f13f63597 to your computer and use it in GitHub Desktop.
Graphing NBA data for quick analysis
This file contains 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
import os | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
PATH = os.path.abspath('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