Puzzle 15: Free-Range
Let's solve a pandas DataFrame puzzle that involves the length function.
We'll cover the following
Guess the output
Try to guess the output of the code below:
import pandas as pddf = pd.DataFrame([[1, 1, 1],[2, 2, 2],[3, 3, 3],[4, 4, 4],[5, 5, 5],])print(len(df.loc[1:3]))
Quiz
Q
What is the output of the code above?
A)
0 1 2
1 2 2 2
2 3 3 3
3 4 4 4
B)
2
C)
3
D)
2 2 2
3 3 3
4 4 4
Get hands-on with 1300+ tech skills courses.