Informatics Practices
The following statement will …………… .
df = df.drop(['Name', 'Class', 'Rollno'], axis = 1) #df is a DataFrame object
- delete three columns having labels 'Name', 'Class' and `Rollno'
- delete three rows having labels 'Name', 'Class' and 'Rollno'
- delete any three columns
- return error
Answer
delete three columns having labels 'Name', 'Class' and `Rollno'
Reason — The drop() function is used to remove rows from a DataFrame. In this case, the axis=1 parameter specifies that we want to drop columns. The list ['Name', 'Class', 'Rollno'] contains the labels of the columns to be dropped. Therefore, the statement will delete the three columns with labels 'Name', 'Class', and 'Rollno' from the DataFrame df.
Related Questions
Which of the following can be used to specify the data while creating a dataframe?
- Series
- List of Dictionaries
- Structured ndarray
- All of these
Which of the following commands shows the information with city="Delhi" from dataframe SHOP?
- print(SHOP[City == 'Delhi'])
- print(SHOP[SHOP.City == 'Delhi])
- print(SHOP[SHOP.'City' == 'Delhi'])
- print(SHOP[SHOP[City] == 'Delhi'])
Assertion (A): Pandas is a Python library.
Reasoning (R): Pandas is a powerful, flexible and easy to use open source data analysis library.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): A series stores data row-wise.
Reasoning (R): A series is a one-dimensional labelled data structure.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.