Reputation: 111
I am creating new columns for a df but I would like to include an if
statement while doing so. My df is just a column of dates.
date
2020-01-01
2020-01-02
...
I want to check if a key is in a list. If yes the df[col] = 1, else 0. The key is equal to str(x + y + date)
for x in list1:
for y in list2:
df[col] = if str(x + y + df['date']) in keylist: 1, else: 0
What would be the best way to structure this? Thank you!
Upvotes: 0
Views: 745