I would like to make an IF condition to set the value in a new column ('new_col'). General idea is like:
if 'Score' = np.nan & 'Year' = 2012: return 1
elif 'Score' == np.nan & 'Year' = 2013: return 2
else: return 'Score'
data = {'year': [2010, 2011, 2012, 2013, 2014], 'Score': [10, 15, np.nan, np.nan, 3]}
df = pd.DataFrame(data, columns = ['year', 'Score'])
year Score
0 2010 10.0
1 2011 15.0
2 2012 1.0
3 2013 2.0
4 2014 3.0
Aucun commentaire:
Enregistrer un commentaire