Nov-16-2021, 12:47 PM
You almost never want to loop through a dataframe. A lot of the point of dataframes is the ability to do things as a vector.
So, not using a loop (this is untested as I don't have your dataframe)
So, not using a loop (this is untested as I don't have your dataframe)
nfl_df['Home Wins'] = (nfl_df['Home Score'] > nfl_df['Visitor Score']) nfl_df['Margin'] = abs(nfl_df['Home Score'] - nfl_df['Visitor Score'])I would also just extract a set of the team names. Using a set eliminates duplicates