What do nlargest() and nsmallest() do and how do they compare to sorting then slicing?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Overview: Asks what nlargest() and nsmallest() return in Pandas and how they compare with sorting a DataFrame and taking the first rows. Tests the cost of selection versus a full sort, tie handling with keep, missing values, and when sort_values is still needed.