Question:

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: Sep 18, 2025
  • print(s1.head(2))
  • print(tail.head())
  • print(tail.head(0))
  • print(tail.head(2))
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Recall head() function.
\texttt{Series.head(n)} returns the first $n$ rows of a Series.
Default $n=5$, but user can specify any number.
Step 2: Evaluate options.
- (1) Incorrect → refers to Series \texttt{s1}, not \texttt{tail}.
- (2) Incorrect → no number specified, gives first 5 rows.
- (3) Incorrect → \texttt{head(0)} returns empty Series.
- (4) Correct → \texttt{tail.head(2)} displays first 2 rows of Series \texttt{tail}.
Step 3: Conclusion.
Only option (4) is valid.
Final Answer: \[ \boxed{\text{print(tail.head(2))}} \]
Was this answer helpful?
0
0

Questions Asked in CUET exam

View More Questions