I have a pandas data frame with three columns. Column A is of datetime type, Column B type is integer, Column C type is float but not important for this question. My goal is to add rows to the data frame determined by each value in Column B, while incrementing the datetime in A by one hour each.
For example, given this data frame:
A B C
4/18/2021 1:00:00 3 1
4/20/2021 5:00:00 2 0
produces this output:
A B C
4/18/2021 1:00:00 3 1
4/18/2021 2:00:00 3 1
4/18/2021 3:00:00 3 1
4/20/2021 5:00:00 2 0
4/20/2021 6:00:00 2 0
A naive approach would be to loop through each row of the data frame adding new rows iteratively, but I prefer to use a more efficient solution to manipulate the data.
O(n)solution be sufficient? As in you'll still need to loop over each data in the original dataframe, but when adding4/18/2021you'll add two rows in one loop.