Worksheet Delete rows-columns from Dataframe

Short Answer Questions (1 Mark questions)

Take a look on this article before going through questions and answers. Delete rows and columns from DataDrame


  1. Which of the following method is used to delete row/column from a dataframe?
    1. delete()
    2. remove()
    3. discard()
    4. drop()
  2. To delete a row from dataframe, which of the following method is correct? A dataframe is indexed with names.
    1. df.drop(df.row_index=’Jay’)
    2. df.drop(‘Jay’)
    3. df.drop(df.row=’Jay’)
    4. df.drop(df[‘Jay’])
  3. Which of the following method is correct for following dataframe to delete row by specifying index name? dt= ({‘Year1’:[1200,1220,1500]}, {‘Year2’:1800,1700,1400})
    df = pd.DataFrame(dt,index=[‘T1′,’T2’])
    Which of the following is correct to delete T2 index record from dataframe?
    1. df.drop(df.index[‘T2’])
    2. df.drop(df.idx=’T2′)
    3. df.drop(index=’T2′)
    4. df.drop(idx=’T2′)
  4. When you perform delete operation on dataframe, it returns a new dataframe always without changing the old dataframe. To avoid this which parameter you will use to change the original dataframe?
    1. intact = True
    2. inplace = True
    3. update = True
    4. replace = True
  5. Ankita is working on dataframe wihch has 4 rows and 3 columns. She wrote df.drop(df.index[[1,3]]). Which rows will be deleted from the dataframe?
    1. Row 1 and Row 3
    2. Rows between 1 and 3
    3. Row 2
    4. All rows from row no. 1 to index row no. 3
  6. Consider the datafame given in Que. No. 3. What happens when we add this statement df.Year1!=1200?
    1. It will delete all rows except 1200 value
    2. It will delete only row with 1200 value
    3. It will delete keep data with 1200 only
    4. None of these
  7. Which parameter is used to add in drop() method to delete columns?
    1. column = n (Where n is column number)
    2. col = n (Where n is column number)
    3. axis = 0
    4. axis = 1

Fill in the blanks:

  1. Mr. Subodh want to keep only three rows from top in his datframe by using a slice with dataframe. So he will write _________ to do the same.
  2. Ms. Nimisha want to ignore last three rows from dataframe by using a slice with dataframe. So she will wirte _______ to do the same.
  3. A dataframe has 4 columns named ID, Cname, PhoneNo and City. To delete PhoneNo and city column from the list using columnnames as parameter, ____________ statement will be used.
  4. To delete rows using list of index as a parameter, _________ statement will be used.
  5. To delete rows and columns together, __________________ statement will be used.



  1. 4. drop()
  2. 2. df.drop(‘Jay’)
  3. 3. df.drop(index=’T2′)
  4. 2. inplace = True
  5. 1. Delete row 1 and row 3
  6. It will delete only row with 1200 value
  7. axis = 1

Fill in the blanks:

  1. df[:3]
  2. df[:-3]
  3. df.drop(columns=[‘PhonNo’,’City’])
  4. df.drop(df.index[[0,1]]) –> To delete rows 0 & 1
  5. df.drop(index=df.index[[1,2]],columns=df.columns[1,2])

Descriptive Questions:

  1. What are the ways to delete rows using drop() method?
  2. What are the ways to delete rows without using drop() method?
  3. What are the ways to delete columns using drop() method?
  4. What are the ways to delete columns without using drop() method?
  5. Consider above dataframe and write statement to
    1. Delete rows with label East and West.
    2. Delete columns Office and Qtr3
  6. Find errors in following statements:
    1. df.delete([‘north’,’south’])
    2. df.drop(index.delete=”North”)
    3. df.drop([“North”,”South”],axis=0)
    4. df.drop(Qtr1,Qtr2)
    5. df.drop(df.iloc[‘North’,’Qrt1′])
    6. df.drop(df.loc[0][‘Qtr4’])
    7. df.drop(df.index[[‘North’,’West’]])
    8. df.drop(df!office[‘HO’])

Comment Your Views

%d bloggers like this: