August 2021
Beginner to intermediate
112 pages
1h 29m
English
| Puzzle 22 | Find Me a Phone Booth |
| | import pandas as pd |
| | |
| | df1 = pd.DataFrame({ |
| | 'id': [1, 2, 3], |
| | 'name': ['Clark Kent', 'Diana Prince', 'Bruce Wayne'], |
| | }) |
| | |
| | df2 = pd.DataFrame({ |
| | 'id': [2, 1, 4], |
| | 'hero': ['Wonder Woman', 'Superman', 'Aquaman'], |
| | }) |
| | |
| | df = pd.merge(df1, df2, on='id') |
| | print(df) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print:
| | id name hero |
| | 0 1 Clark Kent Superman |
| | 1 2 Diana Prince Wonder Woman</code></pre></td> |
Pandas merge ...
Read now
Unlock full access