There is a Pandas dataframe: year date route operator group_name bus_garage bus_park injury_result incident_type victim_category victim_sex victim_age 0 2015 01.01.2015 1 London General Go-Ahead Garage Not Available Southwark Injuries treated on scene Onboard Injuries Passenger Male Child 1 2015 01.01.2015 4 Metroline Metroline Garage Not Available Islington Injuries treated on scene Onboard Injuries Passenger Male Unknown 2 2015 01.01.2015 5 East London Stagecoach Garage Not Available Havering Taken to Hospital – Reported Serious Injury or... Onboard Injuries Passenger Male Elderly Write a grouped_operators function that groups all values by operator column and sums all dates for each unique operator value
import pandas as pd data = {'year':[2015,2015,2015], 'date':['01.01.2015','01.01.2015','01.01.2015'], 'route':[1,4,5], 'operator':['London General','Metroline','East London'], 'group_name':['Go-Ahead','Metroline','Stagecoach'], 'bus_garage':['Southwark','Islington','Havering'], 'bus_park':['Garage Not Available','Garage Not Available','Garage Not Available'], 'injury_result':['Injuries treated on scene','Injuries treated on scene','Taken to Hospital – Reported Serious Injury or...'], 'incident_type':['Onboard Injuries','Onboard Injuries','Onboard Injuries'], 'victim_category':['Passenger','Passenger','Passenger'], 'victim_sex':['Male','Male','Male'], 'victim_age':['Child','Unknown','Elderly']