Question:medium

Which of the following is the correct command to display the top 2 records of Series \texttt{tail}?

Show Hint

Use \texttt{head(n)} to get first $n$ rows and \texttt{tail(n)} to get last $n$ rows of a Series/DataFrame.
Updated On: Feb 16, 2026
  • print(s1.head(2))
  • print(tail.head())
  • print(tail.head(0))
  • print(tail.head(2))
Show Solution

The Correct Option is D

Solution and Explanation

Step 1: Review head() function.
\texttt{Series.head(n)} retrieves the initial $n$ elements of a Series.
By default, $n=5$; users may specify any desired number.
Step 2: Analyze options.
- (1) Incorrect: Refers to Series \texttt{s1}, not \texttt{tail}, and omits the \texttt{tail} call.
- (2) Incorrect: No number specified, resulting in the first 5 rows.
- (3) Incorrect: \texttt{head(0)} yields an empty Series.
- (4) Correct: \texttt{tail.head(2)} displays the first 2 rows of Series \texttt{tail}.
Step 3: Conclusion.
Option (4) is the only valid choice.
Final Answer: \[\boxed{\text{print(tail.head(2))}}\]
Was this answer helpful?
0


Questions Asked in CUET (UG) exam