August 2021
Beginner to intermediate
112 pages
1h 29m
English
| Puzzle 23 | Chain of Commands |
| | import pandas as pd |
| | |
| | df = pd.DataFrame([ |
| | ['133.43.96.45', pd.Timedelta('3s')], |
| | ['133.68.18.180', pd.Timedelta('2s')], |
| | ['133.43.96.45', pd.NaT], |
| | ['133.43.96.45', pd.Timedelta('4s')], |
| | ['133.43.96.45', pd.Timedelta('2s')], |
| | ], columns=['ip', 'duration']) |
| | |
| | by_ip = ( |
| | df['duration'] |
| | .fillna(pd.Timedelta(seconds=1)) |
| | .groupby(df['ip']) |
| | .sum() |
| | ) |
| | print(by_ip) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: ...
Read now
Unlock full access