I have this pandas dataframe, I am trying to assign status identification numbers at Status column to each user depending whether the LAST_ACCESSED column for the user (AD_USER_NAME) is [Offline, = 0, Available/Online = 1, Away = 2] [Table before][1] So that the resulting table will be like this [Table After][2] [1]: https://i.stack.imgur.com/3I5BA.png [2]: https://i.stack.imgur.com/bXuTJ.png I tried to use this code for the 'If function' loop but it didn't work
def flag(df1):
if (df1['LAST_ACCESSED'] = df1['None'] and df1['LAST_ACCESSED'] = 0]):
return 0
elif (df1['LAST_ACCESSED'] > 0 and (df1['LAST_ACCESSED'] = df1['Run_date_Time']):
return 1
elif (df1['LAST_ACCESSED'] > 5 and df1['LAST_ACCESSED'] < df1['Run_date_Time']):
return 2
df1['Status'] = df1.apply(flag, axis = 1)