← Quiz: Time Series with pandas: all 10 questions
Quiz: Time Series with pandas · Question 2 of 10
What does this print? (code)
What does this print?
import pandas as pd
s = pd.Series([10, 12, 15])
print(s.shift(1).tolist())
- A.[12, 15, nan]
- B.[nan, 10.0, 12.0]
- C.[10, 12, 15]
- D.[0, 10, 12]
Answer & explanation
Correct answer: [nan, 10.0, 12.0]
shift(1) moves values down one place, so the first row has no previous value.
Can you get the rest right without peeking?
Take the timed Quiz: Time Series with pandas quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →