I'm trying to assign 1 to any player that matches the name and season of what's inside the MVP array, but I'm having trouble doing so for some reason, and I can't really figure out why it's not working. When I run this, every player is marked with MVP.
Does anyone know why this is happening? I've tried altering the loops and conditions many times, but to no avail.
Here's the code:
import pandas as pd
import numpy as np
import matplotlib as plt
import sklearn as sk
player_stats_total = pd.read_csv('all_seasons.csv')
player_stats_total.fillna(0, inplace=True)
droppedCols = ['player_height', 'player_weight', 'Unnamed: 0', 'player_name', 'team_abbreviation', 'age', 'college', 'country', 'draft_year', 'draft_round', 'draft_number', 'season']
seasons = player_stats_total['season']
seasonsOld = seasons.iloc[1:10101]
seasonsNew = seasons.iloc[10103:10631]
player_stats = player_stats_total.drop(droppedCols, axis=1)
mvps = np.array([['Michael Jordan', '1995-96'],['Karl Malone', '1996-97'], ['Michael Jordan', '1997-98'], ['Karl Malone', '1998-99'],["Shaquille O'Neal", '1999-00'], ["Allen Iverson", '2000-01'], ["Tim Duncan", '2001-02'],["Tim Duncan", '2002-03'],["Kevin Garnett", '2003-04'],["Steve Nash", '2004-05'],["Steve Nash", '2005-06'],["Dirk Nowitzki", '2006-07'],["Kobe Bryant", '2007-08'],["Lebron James", '2008-09'],["Lebron James", '2009-10'],["Derrick Rose", '2010-11'],["Lebron James", '2011-12'],["Lebron James", '2012-13'],["Kevin Durant", '2013-14'],["Stephen Curry", '2014-15'],["Stephen Curry", '2015-16'],["Russell Westbrook", '2016-17'],["James Harden", '2017-18'],["Giannis Antetokounmpo", '2018-19']])
for name in player_stats_total['player_name']:
for mvp in mvps:
if(name == mvp[0]):
for season in player_stats_total['season']:
if(season == mvp[1]):
player_stats['mvp'] = 1
print(player_stats['mvp'].describe())
trainSet = player_stats.iloc[seasonsOld.index]
testSet = player_stats.iloc[seasonsNew.index]
Here's the dataset
Thank you so much!