Lets say I have two pandas DataFrames, df1 and df2, one containing the names and age of people, and the other detailing what they are studying. What is an efficient way to join the two, so that I have boolean fields of what each person is studying?
e.g. given the following
# df1
name | age
------|----
John | 24
Kelly | 49
Gemma | 18
Bob | 29
# df2
name | studies
------|----------
John | education
John | science
Kelly | science
Bob | law
Bob | commerce
How could I create the following dataframe with boolean values for each field of study?
name | age | education | science | law | commerce |
------|-----|-----------|---------|-------|----------|
John | 24 | True | True | False | False |
Kelly | 49 | False | True | False | False |
Gemma | 18 | False | False | False | False |
Bob | 29 | False | False | True | True |