Generation

generate functionFri, 03 Feb 2023

There is a df_new Pandas dataframe: year date route operator group_name district injury_result incident_type victim_category victim_age 0 2015 01.01.2015 1 London General Go-Ahead Southwark 1 Onboard Injuries 7 10 1 2015 01.01.2015 4 Metroline Metroline Islington 1 Onboard Injuries 7 2 2 2015 01.01.2015 5 East London Stagecoach Havering 7 Onboard Injuries 7 8 3 2015 01.01.2015 5 East London Stagecoach None London Borough 7 Onboard Injuries 7 8 4 2015 01.01.2015 6 Metroline Metroline Westminster 5 Onboard Injuries 10 8 generate a unique id for each line of the pandas dataframe

import uuid df_new['id'] = df_new.apply(lambda row: uuid.uuid4(), axis=1)

Questions about programming?Chat with your personal AI assistant