Generation

generate functionTue, 24 Jan 2023

there are two Pandas dataframes: rzd client_id rzd_revenue 0 111 1093 1 112 2810 2 113 10283 3 114 5774 4 115 981 auto client_id auto_revenue 0 113 57483 1 114 83 2 115 912 3 116 4834 4 117 98 Create a new dataframe joined and merge these 2 dataframes inside it

import pandas as pd rzd = pd.DataFrame( { 'client_id': [111, 112, 113, 114, 115], 'rzd_revenue': [1093, 2810, 10283, 5774, 981] } ) auto = pd.DataFrame( { 'client_id': [113, 114, 115, 116, 117], 'auto_revenue': [57483, 83, 912, 4834, 98] } ) def merge_df(rzd, auto): joined = rzd.merge(auto, how='outer', on='client_id') return joined

Questions about programming?Chat with your personal AI assistant