Monday, 31 May 2021

How to merge dataframes

How to merge dataframes:


a=DataFrame({'category':(['electronics','mens clothing', 'womens clothing']),

              'Sales inunit': np.array([7, 3, 5])

              })

b=DataFrame({'category':(['electronics','mens clothing', 'womens clothing']),

              'Sales inunit': np.array([7, 11, 8])

              })


df3=pd.merge(a,b, on ='category', how='left')

No comments:

Post a Comment