题目
题目

ENGG2112 (ND) Quiz 1 (EFT)

单项选择题

Assume the file "data_file.csv" exists and that it contains a column with the heading "age", and you run the following code snippet: import pandas as pd data = pd.read_csv("data_file.csv") sorted_data = data.sort_values(by="age") Which one of the following statements is TRUE?

选项
A.The variable sorted_data will contain all rows in the CSV file sorted from the smallest age to the largest age. There will be an index column displayed when you run sorted_data.head().
B.The variable sorted_data will contain all rows in the CSV file sorted from the smallest age to the largest age. There will not be an index column displayed when you run sorted_data.head().
C.To find the mean age, we have to use the original data frame, i.e. run data["age"].mean() and not the sorted data frame because the sorting may change the mean value.
D.To save the sorted data into a new CSV file, we would use the function save and not a pandas built-in method.
查看解析

查看解析

标准答案
Please login to view
思路分析
The question describes reading a CSV into a DataFrame and then sorting by the 'age' column with sort_values(by="age"). Option 1: This states that sorted_data will contain all rows from the CSV, but arranged in ascending order of age, and that an index column will be displayed when you call sorted_data.head(). In fact, sort_values returns a new DataFrame with the same rows,......Login to view full explanation

登录即可查看完整答案

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

类似问题

更多留学生实用工具

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