Generation

generate functionFri, 03 Feb 2023

There is a df_new Pandas dataframe: year date route operator group_name bus_garage district 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 Calculate the average number of dates for all the operators

def avg_date_by_operator(df_new): # YOUR CODE HERE # raise NotImplementedError() return df_new.groupby("operator").agg("date").mean() df_2015 = pd.read_csv("bus_trucks_2015.csv") avg_date_by_operator(df_2015)

Questions about programming?Chat with your personal AI assistant