🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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())
  1. A.[12, 15, nan]
  2. B.[nan, 10.0, 12.0]
  3. C.[10, 12, 15]
  4. 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 →