Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to merge two excel tables with pandas in python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report