I have the below code:
data['ShortLongFlag'] = data['End DateTime'].apply(lambda x:
-1 if (x.month == 3 and x.date() in shortlongdates == True) else (1 if (x.month == 10 and x.date() in shortlongdates == True) else 0))
What I'm trying to do is the following:
Create a new column in my dataframe which is populated with either -1, 0 or 1 based on the following conditions:
- -1 if the month of the value in my datetime column is equal to 3 and the date is in my list of dates called "shortlongdates"
- 1 if the month of the value in my datetime column is equal to 10 and the date is in my list of dates called "shortlongdates"
- 0 otherwise
Right now all the values are being outputted as 0 in the new column... why?