I have a dataset with date and id columns, and I want to set a third column ‘Status’ where if the date is before the value in the dict/lookup table, then ‘On’, ‘Off’ if on or after the date.
For example:
dict = {‘A’:’1/2/2024′,…}
or look up table =
ID | Date |
---|---|
A | 1/2/2024 |
B | 1/4/2024 |
To achieve:
Date | ID | Status |
---|---|---|
1/1/2024 | A | Off |
1/2/2024 | A | On |
1/3/2024 | A | On |
I know I can merge the lookup table to the main df but trying to use less memory for big datasets.
New contributor
yungkenny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.