Generation

generate functionTue, 24 Jan 2023

Write a pandas function that groups matching columns traffic_source and region and outputs the values of the third column source_type for them

def my_fun(df, var0, var1, var2): return df.groupby([var0, var1])[var2].max().reset_index() my_fun(df, 'traffic_source', 'region', 'source_type')

Questions about programming?Chat with your personal AI assistant