the date column is a timestamp. I am looking to write a if-else condition to manipulate sold to 0 if the date is less than '2021-01-15' and keep as is if the date is greater than or equal to '2021-01-15'. but I keep getting this error: TypeError: unsupported operand type(s) for &: 'str' and 'Timestamp'
date sold
2021-01-01 20
2021-01-02 21
2021-01-03 25
2021-01-04 22
2021-01-05 29
CodePudding user response:
Try this:
df.loc[df['date'] < '2021-01-15', 'sold'] = 0