0

Hi wondering if someone can work their 'Python Magic' for me!

I have a large set of data that falls between a range of 3 dates (a small sample is in the image file)

excel image of data

So far I have imported the data into pandas and have converted the Start date from an object to a date stamp.

I would like to add a column to the data where by the value in the column is specific to the Start date. so for example for any start dates that fall between the 26/11/2020 - 28/12/2020 the column would contain "W20", for any Start dates that fall between 29/03/2021 and 25/10/2021 the column would then say " S20" and for dates between 23/11/2021 and 30/12/2021 the column would say "W21"

I have tried using Numpy to create a conditions list and then assign values and use numpy select to create a new column but with little success. can anyone help?

thanks and apreciate you skills if you have any suggestions :)

  • So I found the answer in the following post: https://stackoverflow.com/questions/53553557/add-a-column-value-depending-on-a-date-range-if-else – Chris Barton Sep 19 '20 at 21:34

1 Answers1

0

you might also check out this previous answer;[Select DataFrame rows between two dates1

itprorh66
  • 3,110
  • 4
  • 9
  • 21