August 2021
Beginner to intermediate
112 pages
1h 29m
English
| Puzzle 10 | Free Range |
| | import pandas as pd |
| | |
| | nums = pd.Series([1, 2, 3, 4, 5, 6]) |
| | print(nums[(nums > 2) and (nums < 5)]) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will raise a ValueError.
The result of nums>2 is a series of Boolean values:
| | In [1]: nums>2 |
| | Out[1]: |
| | 0 False |
| | 1 False |
| | 2 True |
| | 3 True |
| | 4 True |
| | 5 True |
| | dtype: bool |
We can use this Boolean series to select parts ...
Read now
Unlock full access