1

I am trying to add a column that flags those line items with End Dates in the next 1,2,3,4 weeks, but using the below code has been just overwriting itself (which makes sense). Is there an easy way to add this grouping?

Essentially, in Excel terms, I am trying to do an embedded IF statement (IF Date < TODAY() , X , IF Date < TODAY() + 7, Y, IF...)

sup['Availability'] = sup['End Date'].apply(lambda x: ' Now Available' if x < date.today() else sup['End Date'])
sup['Availability'] = sup['End Date'].apply(lambda x: '1 Week' if x < date.today() + timedelta(weeks=1) else sup['First Available Date'])
sup['Availability'] = sup['End Date'].apply(lambda x: '2 Week' if x < date.today() + timedelta(weeks=2) else sup['First Available Date'])
sup['Availability'] = sup['End Date'].apply(lambda x: '3 Week' if x < date.today() + timedelta(weeks=3) else '4 Weeks')

RCarmody
  • 712
  • 1
  • 12
  • 29

0 Answers0