Reputation: 37
DataOrigin['isholiday'] = DataOrigin['arrival'].apply(lambda x: 1 if x=='2016-06-10'or'2016-06-09'or '2016-06-11'else 0)
Please click on the image first, above is my code My description is including in the picture, aprreciated!
Upvotes: 0
Views: 114
Reputation: 109528
You can use isin
to check if the values are in a given subset of data.
DataOrigin['isholiday'] = DataOrigin['arrival'].isin(['2016-06-10', '2016-06-09', '2016-06-11'])
If you really want ones and zeroes instead of True/False, just append .astype(int)
to the statement above. True/False should evaluate the same as 1/0, so it is really down to preference or your specific use case.
Upvotes: 2