df.sort_values('score') is called on a float column containing NaN. Where do the missing values end up?
Correct answer
C. At the end by default, because na_position defaults to last in sort_values
14 views
C. At the end by default, because na_position defaults to last in sort_values
14 views
na_position controls where missing values land and defaults to 'last' in sort_values, independently of whether the sort is ascending. This differs from NumPy's sort, where NaN propagates to the end only because of its comparison semantics. Use df.sort_values('score', na_position='first') when missing records should lead the report.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.