Informatics Practices

The following statement will …………… .

df = df.drop(['Name', 'Class', 'Rollno'], axis = 1) #df is a DataFrame object
  1. delete three columns having labels 'Name', 'Class' and `Rollno'
  2. delete three rows having labels 'Name', 'Class' and 'Rollno'
  3. delete any three columns
  4. return error

Python Data Handling

1 Like

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.

Answered By

3 Likes


Related Questions