I have a pyspark df with an hour column (int) like this:
| hour |
|---|
| 0 |
| 0 |
| 1 |
| ... |
| 14 |
And I have an execution_datetime variable that looks like 2022-01-02 17:23:11
Now I want to calculate a new column for my DF that holds my execution_datetime but the hour is replaced by the values from the hour col. Output should look like:
| hour | exec_dttm_with_hour |
|---|---|
| 0 | 2022-01-02 00:23:11 |
| 0 | 2022-01-02 00:23:11 |
| 1 | 2022-01-02 01:23:11 |
| ... | ... |
| 14 | 2022-01-02 14:23:11 |
I know there are ways using i.e. .collect(), then edit the list and insert as new col. But I need to make use of sparks parallel execution since it could be a super high data load. Also, casting it to pandas and then editing it is not suitable for my use case.
Thanks in advance for any suggestions!