lundi 7 janvier 2019

np select if statement to return a value for a conditional statement

I want to create a new column that returns a value of 1 if the condition below is true and 2 if false and am not sure why the below isn't working?

t1 = pd.x['timestamp_1'] < x['timestamp_2']


x['new'] = np.select([t1], [1], default=2)

Aucun commentaire:

Enregistrer un commentaire