Consider the following DataFrame Gr and answer any four questions from (i)- (v) Name Age0 Rashmi A11 Harsh A22 Ganesh B13 Priya A14 Vivek B25 Anita A26 Karthik A1 5. Write down the command that will give the following output. Name Age0 Rashmi A11 Harsh A22 Ganesh B13 Priya A14 Vivek B2*1 pointa. print(Gr.iloc[0:5])b. print(Gr[0:5])c. Bothd. None6. The teacher needs to add a column called Percentage with the following data [92,89,None,95,68,None,93] Help her to identify the correct set of statement/s from the given options :*1 pointa. Gr.column[‘Percentage’]=[92,89,None, 95,68,None ,93]b. Gr[‘ Percentage’]=[92,89,None, 95,68,None ,93]c. Gr.loc[‘Percentage’]= [92,89,None,95,68,None,93]d. Both (b) and (c) are correct7. Which of the following statement/s will drop the column Grade by name?*1 pointa. Gr.drop[‘Grade’]b. Gr.drop(‘Grade’, axis=1)c. Both a & bd. None of the above8. Which of the following command will display the column labels of the DataFrame?*1 pointa. print(Gr.columns())b. print(Gr.column())c. print(Gr.column)d. print(Gr.Columns)
Question
Consider the following DataFrame Gr and answer any four questions from (i)- (v) Name Age0 Rashmi A11 Harsh A22 Ganesh B13 Priya A14 Vivek B25 Anita A26 Karthik A1 5. Write down the command that will give the following output. Name Age0 Rashmi A11 Harsh A22 Ganesh B13 Priya A14 Vivek B2*1 pointa. print(Gr.iloc[0:5])b. print(Gr[0:5])c. Bothd. None6. The teacher needs to add a column called Percentage with the following data [92,89,None,95,68,None,93] Help her to identify the correct set of statement/s from the given options :*1 pointa. Gr.column[‘Percentage’]=[92,89,None, 95,68,None ,93]b. Gr[‘ Percentage’]=[92,89,None, 95,68,None ,93]c. Gr.loc[‘Percentage’]= [92,89,None,95,68,None,93]d. Both (b) and (c) are correct7. Which of the following statement/s will drop the column Grade by name?*1 pointa. Gr.drop[‘Grade’]b. Gr.drop(‘Grade’, axis=1)c. Both a & bd. None of the above8. Which of the following command will display the column labels of the DataFrame?*1 pointa. print(Gr.columns())b. print(Gr.column())c. print(Gr.column)d. print(Gr.Columns)
Solution
-
The correct command to get the output is: c. Both Both commands Gr.iloc[0:5] and Gr[0:5] will give the same output.
-
The correct set of statement to add a column called Percentage is: b. Gr['Percentage']=[92,89,None, 95,68,None ,93] This will add a new column 'Percentage' to the DataFrame Gr.
-
The correct statement to drop the column Grade by name is: b. Gr.drop('Grade', axis=1) This will drop the column named 'Grade' from the DataFrame Gr.
-
The correct command to display the column labels of the DataFrame is: a. print(Gr.columns) This will print the column labels of the DataFrame Gr.
Similar Questions
EasyCompaniesHintWrite a solution to create a DataFrame from a 2D list called student_data. This 2D list contains the IDs and ages of some students.The DataFrame should have two columns, student_id and age, and be in the same order as the original 2D list.The result format is in the following example. Example 1:Input:student_data:[ [1, 15], [2, 11], [3, 11], [4, 20]]Output:+------------+-----+| student_id | age |+------------+-----+| 1 | 15 || 2 | 11 || 3 | 11 || 4 | 20 |+------------+-----+Explanation:A DataFrame was created on top of student_data, with two columns named student_id and
tudent_data = data.frame(student_id=c(1:4), student_name=c(‘Ram’,‘Harish’,‘Pradeep’,‘Rajesh’))1 pointChoose the correct command to add a column named student_dept to the dataframe student_data. student_datastudent_dept=c(“Commerce”, “Biology”, “English”, “Tamil”) student_data[“student_dept”]= c(“Commerce”,“Biology”, “English”,“Tamil”) student_dept= student_data[c(“Commerce”,“Biology”,“English”,“Tamil”)] None of the above
Write command to create a dataframe to store marks of 3 subjects . columns can be named as ["GE", "SEC","VAC "]. Rows are indexed by rollno of the students [25,30,50]
4.Question 4Use this dataframe to answer the question.How would you select the Genre disco? Select all that apply.1 pointdf.iloc[6, ‘genre’]df.loc[6, 5]df.iloc[6, 4]df.loc[‘Bee Gees’, ‘Genre’]5.Question 5Use this dataframe to answer the question.Which will NOT evaluate to 20.6? Select all that apply.1 pointdf.iloc[4,5]df.iloc[6,5]df.loc[4,’Music Recording Sales’]df.iloc[6, ‘Music Recording Sales (millions)’]6.Question 6Use this dataframe to answer the question.How do we select Albums The Dark Side of the Moon to Their Greatest Hits (1971-1975)? Select all that apply.1 pointdf.iloc[2:5, ‘Album’]df.loc[2:5, ‘Album’]df.iloc[2:6, 1]df.loc[2:5, 1]
Select the correct answerWhat will be the output of the following Python code?def ct(x, y, z): global a x = 5 y = 6 z = 7 a = 8 print(x,y,z,a)x,y,z,a = 15,16,17,18ct(1,3,9)Options5 6 7 81 5 9 1815 16 17 181 5 9 8
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.