0

I am trying to create a new column called 'delayed_or_not' by iterating over the rows to assign 'delayed' when the 'Shipment_day_Scheduled' column is less than the 'Order_to_shipment_day' column and assign 'not delayed' if otherwise. However, only my if statement is running thereby assigning delayed to all the rows even when the condition is not met.enter image description here

I tried using an if and else statement embedded in a for loop. I was expecting for example; the column 'delayed_or_not' to be 'Not delayed' in the second row but i got 'delayed'

  • please provide your data and code in a [reproducible format](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples): **text**, not images. – mozway Jul 19 '23 at 09:35
  • You need to use `shift`, never use `iterrows` in pandas – mozway Jul 19 '23 at 09:36

0 Answers0