题目
题目
多项选择题

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

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

查看解析

标准答案
Please login to view
思路分析
To determine which options sort the DataFrame df by the Salary column in ascending order and modify df in place, I’ll evaluate each choice against how pandas sort_values behaves. Option 1: df.sort_values(by = 'Salary') This call specifies the column to sort by but omits the inplace parameter, which defaults to inplace=False. That means it returns a new, ......Login to view full explanation

登录即可查看完整答案

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

类似问题

更多留学生实用工具

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