0

I have two dataframes with similar records and yet the customer have different roles in each table. I wonder if it's possible to update the "CUST_ID" in the "customer_df2" dataframe with the "customer_df1" dataframe. I have been digging through the internet and yet couldn't find any solutions.

import pandas as pd
customer_data_1 = {'TRANSACTION_ID':['001','002','003'],
                    'NAME':['Amy','Amy','Amy'],
                    'CUST_ID':[100,100,100],
                    'ROLE':['APPLICANT','APPLICANT','APPLICANT']}
customer_df1 = pd.DataFrame(customer_data_1)

customer_data_2 = {'TRANSACTION_ID':['B001','B002','B003'],
                    'NAME':['Amy','Amy','Amy'],
                    'CUST_ID':[None,None,None],
                    'ROLE':['BENEFICIARY','BENEFICIARY','BENEFICIARY']}
customer_df2 = pd.DataFrame(customer_data_2)



  • It depends on the expected output, if the DataFrames are already aligned, simply `df1.update(df2)` – mozway Nov 10 '22 at 07:40
  • I am sorry for not being clear enough. I only want to update the "CUST_ID" column in the "customer_df2" dataframe and keep the rest of the columns in the "customer_df2" dataframe as is. – Ricky Shie Nov 10 '22 at 07:46

0 Answers0