1In [41]:
2df.loc[df['First Season'] > 1990, 'First Season'] = 1
3df
4
5Out[41]:
6 Team First Season Total Games
70 Dallas Cowboys 1960 894
81 Chicago Bears 1920 1357
92 Green Bay Packers 1921 1339
103 Miami Dolphins 1966 792
114 Baltimore Ravens 1 326
125 San Franciso 49ers 1950 1003
1# np.where function works as follows:
2import numpy as np
3
4# E.g. 1 - Set column values based on if another column is greater than or equal to 50
5df['X'] = np.where(df['Y'] >= 50, 'yes', 'no')
6
7# E.g. 2 - Replace values over 20000 with 0, otherwise keep original value
8df['my_value'] = np.where(df.my_value > 20000, 0, df.my_value)