Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Created August 21, 2014 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbengfort/eefc7fe5b66f13f63597 to your computer and use it in GitHub Desktop.
Save bbengfort/eefc7fe5b66f13f63597 to your computer and use it in GitHub Desktop.
Graphing NBA data for quick analysis
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