carpentries-incubator / python-business

Python for Business
https://carpentries-incubator.github.io/python-business/
Other
8 stars 15 forks source link

practice answer incorrect #10

Open yuanxiesa opened 3 years ago

yuanxiesa commented 3 years ago

Lesson 5: working with tabular data (another name to distinguish from lesson 3)

Merge soda and inv tables, call it inv_soda.

Not all kinds of soda will appear in the invoice (as some were never sold). If we want to keep everything in the soda dataframe, what kind of join should we use?

current answer:

inv_soda = inv.merge(soda, how="left", right_on="Item_id", left_on="Item_id")

Left join will leave you all invoices. Still won't have records about the soda never sold. Should be outer join.

inv_soda = inv.merge(soda, how="outer", right_on="Item_id", left_on="Item_id")