So, I have two Excel tables that I am looking to merge, on my MacBook. They're quite large. One has dimensions (42912, 6)
and the other has dimensions (41424,7)
. Therefore, here are a couple of examples of what they look like:
Table A
| Country | Continent |
|------------- |--------------- |
| UK | Europe |
| France | Europe |
| Germany | Europe |
| USA | North America |
| New Zealand | Oceania |
Table B
| Country | City | Population |
|------------- |---------- |------------ |
| UK | London | 8,900,000 |
| | Bristol | 53,907 |
| France | Paris | 2,141,000 |
| USA | New York | 8,623,000 |
| New Zealand | Auckland | 1,657,000 |
You can see some of the differences between the two. For example, whilst Table A lists 5 countries, Table B is missing one of them - Germany
. In addition. Table B has 2 cities listed under UK
, where Table A only has one row.
Basically, I want to be able to merge the two tables, so they look like this:
| Country | Continent | City | Population |
|------------- |--------------- |---------- |------------ |
| UK | Europe | London | 8,900,000 |
| | | Bristol | 53,907 |
| France | Europe | Paris | 2,141,000 |
| Germany | Europe | | |
| USA | North America | New York | 8,623,000 |
| New Zealand | Oceania | Auckland | 1,657,000 |
The two tables are being merged by the Country
string/column which they both have in common, effectively adding the remaining relevant rows from Table B, to Table A.
When Table A has a row that Table B doesn't, the columns are just left empty (Germany
row as an example). When Table B has multiple rows in the same country, additional rows are created in Table A (UK
as an example) to accommodate.
I would really appreciate some help in understanding how I can merge these two (given they have over 40k rows each) rather than doing it line by line in Excel, which would take ages.
I'm quite happy to work with Python or Matlab etc., or even simpler - a way to do it in Excel for Mac.
Thanks!