I have a dataset of every player in the NBA and their stats since 1950. The columns in the dataset consist of the Year, which is the applicable year, player names and his team for that year, years in the NBA, and 20 columns of different stats for every player in every year of his career. One of the columns is 'PTS', which is the total number of points the player has scored that year. I want to create a scatter plot in Python that shows the Years 1950 through 2017 on the x-axis and the total points scored in that year on the y-axis. I believe the most efficient way to return the total points for each season is:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
seasons = pd.read_csv('C:/windows/temp/Seasons_Stats.csv')
tp_yr = seasons.groupby('Year').agg({'PTS': ['sum']})
But creating the scatter plot using:
tp_yr.plot.scatter( x= 'Year', y = 'PTS', s = 'None', c='red')
returns:
KeyError: 'Year'
and a blank graph I want the total points in a year for all the years from 1950 -2017 represented in a red scatter plot.