题目
题目
多项选择题

Question27 The Pandas DataFrame df is generated using the below code. import pandas as pddf=pd.DataFrame({'Salary':[50,100,75]}) Which option(s) can sort the DataFrame df by Salary column from top row being the lowest Salary to the last row being the highest Salary, and modify the DataFrame df directly? Select one or more alternatives: df.sort_values(by = 'Salary', ascending = False, inplace = True) df.sort_values(by = 'Salary', inplace = True) df.sort_values(by = 'Salary', ascending = True, inplace = True) df.sort_values(by = 'Salary') ResetMaximum marks: 3 Flag question undefined

选项
A.df.sort_values(by = 'Salary', ascending = False, inplace = True)
B.df.sort_values(by = 'Salary', inplace = True)
C.df.sort_values(by = 'Salary', ascending = True, inplace = True)
D.df.sort_values(by = 'Salary')
查看解析

查看解析

标准答案
Please login to view
思路分析
We are asked which options can sort the DataFrame df by the Salary column from the lowest salary at the top to the highest salary at the bottom, and modify df directly. Option 1: df.sort_values(by = 'Salary', ascending = False, inplace = True) - This uses ascending = False, which sorts in descending order (highest to lowest). Since the requiremen......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!