Puzzle 18: Off with Their NaNs
Let's solve a NaN puzzle.
We'll cover the following
Guess the output
Try to guess the output of the code below:
import numpy as npimport pandas as pds = pd.Series([1, np.nan, 3])print(s[~(s == np.nan)])
Quiz
Q
What is the output of the code above?
A)
0 1.0
2 3.0
B)
0 1.0
1 NaN
2 3.0
C)
IndexError
D)
RuntimeError
Get hands-on with 1300+ tech skills courses.