August 2021
Beginner to intermediate
112 pages
1h 29m
English
| Puzzle 18 | Off with Their NaNs |
| | import numpy as np |
| | import pandas as pd |
| | |
| | s = pd.Series([1, np.nan, 3]) |
| | print(s[~(s == np.nan)]) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print:
| | 0 1.0 |
| | 1 NaN |
| | 2 3.0 |
| | dtype: float64 |
We covered some of the floating-point oddities in the puzzle Puzzle 12, Multiplying . NaN (or np.nan) is another oddity. The name NaN stands for ...
Read now
Unlock full access