Difference between revisions of "Merge Excel Spreadsheet with same columns"

From rbachwiki
Jump to navigation Jump to search
(Created page with "=Merge two spreadsheets= '''Merge two or more spreets from different files with similar columns, but choose which columns you want to include in the merge''' <pre> import pan...")
 
 
Line 19: Line 19:
</pre>
</pre>


==[[#top|Back To Top]] - [[Python|Category]]==
==[[#top|Back To Top]] - [[Python|Main Category]]/[[Python_Excel_Related| Excel Category]]==
[[Category:Python]]
[[Category:Python]]

Latest revision as of 16:25, 2 September 2020

Merge two spreadsheets

Merge two or more spreets from different files with similar columns, but choose which columns you want to include in the merge

import pandas as pd
file1 = 'wall1.xlsx'
file2 = 'wall2.xlsx'

wall1 = pd.read_excel(file1)
wall2 = pd.read_excel(file2)

values1 = wall1[['SKU','ProductType','SA3']]
values2 = wall2[['SKU','ProductType','SA3']]

dataframes = [values1, values2]
join = pd.concat(dataframes)
join.to_excel("output.xlsx")

Back To Top - Main Category/ Excel Category