CBSE Class 12 Informatics Practices Question 45 of 167

Python Pandas — I — Question 10

Back to all questions
10
Question

Question 10

To display first three elements of a Series object S, you may write ............... .

  1. S[:3]
  2. S[3]
  3. S[3rd]
  4. all of these
Answer

S[:3]

Reason — The syntax to extract slices from Series object is <Series Object>[start:end:step]. Therefore, according to this syntax, the correct slice notation to display the first three elements of a Series object S is S[:3].