Generation

generate functionFri, 03 Feb 2023

generate a unique id for each line of the pandas dataframe

import pandas as pd def get_line_id(row): return row.name df['line_id'] = df.apply(lambda row: get_line_id(row), axis=1)

Questions about programming?Chat with your personal AI assistant