happy Friday! I am trying to create additional columns in a dataframe (one for each hour) and populate with 0 or 1 depending if the shop is open or not. A simplified version of my data set is:
| Shop | Days | Open | Close |
|---|---|---|---|
| Boots | Mon - Sat | 09:00 | 17:00 |
| HMV | Mon - Sat | 08:00 | 20:00 |
| Screwfix | Sun | 10:00 | 19:00 |
| Tesco | Mon - Fri | 06:00 | 13:00 |
I'm hoping to end up with three sets (mon-fri,sat,sun) of 24 columns each (00:00-23:00) added on so it should look something like:
| Shop | Days | Open | Close | mon-fri 08:00 | mon-fri 09:00 | ... | sat 11:00 | ... | sun 13:00 |
|---|---|---|---|---|---|---|---|---|---|
| Boots | Mon - Sat | 09:00 | 17:00 | 0 | 1 | ... | 1 | ... | 0 |
| HMV | Mon - Sat | 08:00 | 20:00 | 1 | 1 | ... | 1 | ... | 0 |
| Screwfix | Sun | 10:00 | 19:00 | 0 | 0 | ... | 0 | ... | 1 |
| Tesco | Mon - Fri | 06:00 | 13:00 | 1 | 1 | ... | 0 | ... | 0 |
I am anticipating needing to create a list of all hours between open and close times and then some if/where conditions to populate the corresponding columns. However, I'm not sure if there is a simpler way and/or how to go about including column headers in my conditions.
Any help is greatly appreciated. Thank you in advance.