'How do I convert a dataframe with time-periods into a particular format?
My initial dataframe looks as follows:
| User | License | Status | Start-Date | End-Date |
|---|---|---|---|---|
| A | xy | access | 10.01.2022 | 13.01.2022 |
| B | xy | access | 11.01.2022 | 14.01.2022 |
| C | xy | access | 11.01.2022 | 14.01.2022 |
| A | xy | access | 12.01.2022 | 15.01.2022 |
| A | xy | access | 14.01.2022 | 17.01.2022 |
| B | xy | access | 21.01.2022 | 24.01.2022 |
| A | xy | access | 21.01.2022 | 24.01.2022 |
There are three users (a, b, c) who request a license on different days. In principle, the end date is always three days later than the start date due to the fact that a license is locked for a period of 3 days.
For example, if user A accesses again within these three days, the period is extended again by three days.
My (ultimate) goal is to get a graph like the following:

So i can see how many licenses were blocked.
But this is just my goal in a later step. I thought the best way to achieve an output like this would be the following table (dataframe) in a next step and just plotting Sum over Date:
| Date | A | B | C | Sum |
|---|---|---|---|---|
| 10.01.2022 | 1 | 0 | 0 | 1 |
| 11.01.2022 | 1 | 1 | 1 | 3 |
| 12.01.2022 | 1 | 1 | 1 | 3 |
| 13.01.2022 | 1 | 1 | 1 | 3 |
| 14.01.2022 | 1 | 1 | 1 | 3 |
| 15.01.2022 | 1 | 0 | 0 | 1 |
| 16.01.2022 | 1 | 0 | 0 | 1 |
| 17.01.2022 | 1 | 0 | 0 | 1 |
| 18.01.2022 | 0 | 0 | 0 | 0 |
| 19.01.2022 | 0 | 0 | 0 | 0 |
| 20.01.2022 | 0 | 0 | 0 | 0 |
| 21.01.2022 | 1 | 1 | 0 | 2 |
| 22.01.2022 | 1 | 1 | 0 | 2 |
| 23.01.2022 | 1 | 1 | 0 | 2 |
| 24.01.2022 | 1 | 1 | 0 | 2 |
(But I am not sure if this is the best way to achieve it.)
Would that be possible with pandas? If yes, how? Tbh I have no clue. I hope I didn't explain the question too complicated.
So I'm only concerned with the second dataframe, how I get it, not the graph itself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
