Home > Back-end >  How to merge dataframes based on column names?
How to merge dataframes based on column names?

Time:11-17

I have two tables (data frames). 1. One that contains years and production. 2. Another that contains years and area. I want to merge these two and get results as shown in table 3. How to do this is python3 (preferably using pandas)?

Table1

Table 1

Table2

Table 2

Result table:

Result table

CodePudding user response:

IIUC use:

df = pd.concat([df1, df2]).T

CodePudding user response:

Try using this:

Dataframe df3    
df3 = pd.merge(df1, df2, on='Years')
  • Related