df.head(10).to_clipboard(sep=';', index=True)
I have a dataframe as above and I have the following column descriptions
• Id - the uuid of this delivery
• PlanId - the uuid of the plan (the plan for deliveries of a given day)
• PlanDate - the date of delivery
• MinTime - the minimal time (seconds from midnight) for delivering this delivery
• MaxTime - the maximal time (seconds from midnight) for delivering this delivery
• RouteId - the uuid of the route this delivery belongs to
• ETA - the estimated time for arrival of this delivery on this date (from the eta you can of course order the deliveries in a route)
• TTN - the time to next delivery in the route, i.e., at index 3 that would be the time distance between delivery index 3 and delivery index 4
• DTN - the distance to next delivery in the route.
I need to find the the median of deliveries per route in the given plan.
the median distance travelled per route in the given plan.
the median time travelled per route in the given plan.
How may I do this?
I am wondering if this is just straightforward calculation of median where you just group by and aggregate I tried something like this to find the median distance
Tx = df.groupby(by=['plan_id','route_id'], as_index=False)['dtn'].sum()
Tx.groupby(['plan_id','route_id'])['dtn'].median()
However I might not sure if this correct.
