title: Working in Pandas Error: index 0 is out of bounds for axis 0 with size 0
body: <p>So I am using NHL player stats and I want to predict the total points a player will get in the next season given their previous season stats. I am trying to create a column on the dataframe called "Next_Year_Points" but I keep receiving the same error: <em>index 0 is out of bounds for axis 0 with size 0</em>. My relevant dataframe columns are 'Player', 'Season', and 'PTS'. </p>
  
  <pre><code>def GetPTS(player, year):
      next_year_row = X_train[(X_train['Player'] == player) &amp; (X_train['Season'] == year+1)]
      next_year_pts = next_year_row['PTS'].values[0]
      return next_year_pts
  
  Next_Year_Points = []
  for index, row in X_train.iterrows():
      nxt_yr_pts.append(GetPTS(row['Player'], row['Season']))
  </code></pre>
  
  <p>When I use my custom function on its own it works ie. GetPTS('Sidney Crosby', 2017) will return his 2018 points. However, when I loop through the dataframe to create a list of next year's points I get the error.</p>
  
  <p>Apologies if my formatting is terrible or I am missing information, this is my first post.</p>
  
  <p>TIA</p>