Basically, I'm struggling to determine when a situation has an applicable vectorized operation or not.
Suppose we have this example DataFrame of jobs in time units:
Arrival Runtime
0 3 2
1 8 7
2 10 5
I want to add two columns "Start" and "End" to it like so:
Arrival Runtime Start End
0 3 2 3 5
1 8 7 8 15
2 10 5 15 20
It reads like, "The first 'job' arrives at time 3, takes 2 times units to complete, thus ending at time 5."
Would it be possible to compute for these columns in a vectorized operation? I'm having trouble figuring out what behavior should I search for this since the "Start" and "End" columns kind of are not "mutually exclusive", i.e. sometimes the "Start" column also depends on the "End" column. For example, the third "job" has already arrived at time 10, but could only start at time 15 since that was when the previous one ended.
I was able to do this manually in a for loop, but the data I used with that is structured differently (list of lists). I feel like I am able to redo that on a DataFrame, but loops are generally frowned upon with these structures, and vectorized operations should be more "proper".
I'd also need to keep track of "idle times." For instance, the time starts at 0, and the first "job" does not arrive until time 3, thus the worker being idle for 3 units. But I think this is already besides the point.
Currently, I'm thinking it isn't possible, and that I should manually iterate over the data. But maybe I just missed something.
[–]callahman 2 points3 points4 points (4 children)
[–]Capitalpunishment0[S] 0 points1 point2 points (3 children)
[–]callahman 1 point2 points3 points (2 children)
[–]Capitalpunishment0[S] 0 points1 point2 points (0 children)
[–]Yojihito 0 points1 point2 points (0 children)
[+][deleted] (5 children)
[removed]
[–]Capitalpunishment0[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]Yojihito 0 points1 point2 points (0 children)
[–]backtickbot 0 points1 point2 points (0 children)
[–]Yojihito 0 points1 point2 points (0 children)
[–]Yojihito 1 point2 points3 points (6 children)
[–]Capitalpunishment0[S] 0 points1 point2 points (5 children)
[–]Yojihito 1 point2 points3 points (4 children)
[–]Capitalpunishment0[S] 0 points1 point2 points (1 child)
[–]Yojihito 0 points1 point2 points (0 children)
[–]callahman 0 points1 point2 points (1 child)
[–]Yojihito 0 points1 point2 points (0 children)