oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Outer Merge #388

Open oldoc63 opened 1 year ago

oldoc63 commented 1 year ago

In the previous exercise, we saw that when we merge two DataFrames whose rows don't match perfectly, we lose the unmatched rows.

This type of merge (where we only include matching rows) is called an inner merge. There are other types of merges that we can use when we want to keep information from the unmatched rows.

Suppose that two companies, Company A and Company B have just merged. They each have a list of customers, but they keep slightly different data. Company A has each customer's name and email. Company B has each customer's name and phone number. They have some customers in common, but some are different.

oldoc63 commented 1 year ago

If we wanted to combine data from both companies without losing the customers who are missing from one of the tables, we could use an Outer Join. An Outer Join would include all rows from both tables, even if they don't match. Any missing values are filled in with None or nan (which stand for "Not a Number").

oldoc63 commented 1 year ago

There are two hardware stores in town: Store A and Store B. They have decided to merge into one big Super Store! Combine the inventories of Store A and Store B using an outer merge. Save the results to the variable store_a_b_outer. Display store_a_b_outer using print.