Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to merge two excel tables with pandas in python

Shulou Source: shulou.com Published: 2022-06-02 07:17:58 10月31日 Update

This article introduces how to use pandas to merge two excel tables in python, the content is very detailed, interested friends can refer to it, I hope it can be helpful to you.

In our work, we often encounter situations where we need to merge the records in the table, as shown in the following figure:

The following results need to be obtained:

I'll do the above with a few lines of python code:

Import pandas as pd

# read table 1 (parameters are 1 workbook name and its directory, 2 which table)

Df1 = pd.read_excel (ringing DureGetMyExcelUniple 1.xlsxexamples, 'Sheet1')

# read table 2 (parameters are 1 workbook name and its directory, 2 which table)

Df2 = pd.read_excel (ringing DureGetMyExcelUniple 2.xlsxexamples, 'Sheet1')

# join the results by row. The input parameter is the list, and the content in the list is the content you need to merge.

Df = pd.concat ([df1, df2])

# to output the result to an excel table, you need to set index=None

# index means that when reading a table, pandas will add an index per row by default if it is not specified, and the default added index needs to be deleted when outputting

Df.to_excel (ringing excel excel) about how to use pandas to merge two Excelsio tables in python is here. I hope the above content can help you to learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Content results work parameters name more catalog index don't help output good code interest function guy partner situation article is in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi Shulou Tech Info Linux Docker