0

I have two dataframes:

  • df_a
  • df_b

df_a have data from SQL Server table with more than 120 columns. In this table each row is indicators (kpi's) from some project in a such date df_b came from excel and is a subset of kpi's in df_a

index to join dataframes: 'wind_farm' and 'reference' (reference is in yyyy-mm-dd format)

in df_b, has data to update in last months, and new data to add this month for each project

O just want to update df_a with new and updated data from df_b.

I tried using pd.merge(df_a, df_b, on=[ 'wind_farm', 'reference'], how='outer') but pandas just created new columns with prefixes.

Then i tried removing all "_x" and replacing with all "_y" columns, but this changes my table columns data types and removed all data that not in excel file.

I have two dataframes:

  • df_a
  • df_b

df_a have data from SQL Server table with more than 120 columns. In this table each row is indicators (kpi's) from some project in a such date df_b came from excel and is a subset of kpi's in df_a

index to join dataframes: 'wind_farm' and 'reference' (reference is in yyyy-mm-dd format)

in df_b, has data to update in last months, and new data to add this month for each project

O just want to update df_a with new and updated data from df_b.

I tried using pd.merge(df_a, df_b, on=[ 'wind_farm', 'reference'], how='outer') but pandas just created new columns with prefixes.

Then i tried removing all "_x" and replacing with all "_y" columns, but this changes my table columns data types and removed all data that not in excel file.

  • 2
    Welcome to stack overflow! This is a lot of description, but it's hard to understand without a [mre]. Please have a look at [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and [edit] your question to include a sample of your input dataframes and your expected output, so that we can understand better – G. Anderson Mar 15 '23 at 18:17

0 Answers0