In this article we are going to discuss delete row columns pandas questions for ip class 12.
Topics Covered
delete row columns pandas questions
Let’s start this article with objective type delete row columns pandas questions for class 12 informatics practices.
Short Answer Questions (1 Mark questions)
Take a look on this article before going through questions and answers.
MCQs
- Which of the following method is used to delete row/column from a dataframe?
- delete()
- remove()
- discard()
- drop()
- To delete a row from dataframe, which of the following method is correct? A dataframe is indexed with names.
- df.drop(df.row_index=’Jay’)
- df.drop(‘Jay’)
- df.drop(df.row=’Jay’)
- df.drop(df[‘Jay’])
- 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?- df.drop(df.index[‘T2’])
- df.drop(df.idx=’T2′)
- df.drop(index=’T2′)
- df.drop(idx=’T2′)
- 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?
- intact = True
- inplace = True
- update = True
- replace = True
- 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?
- Row 1 and Row 3
- Rows between 1 and 3
- Row 2
- All rows from row no. 1 to index row no. 3
- Consider the datafame given in Que. No. 3. What happens when we add this statement df.Year1!=1200?
- It will delete all rows except 1200 value
- It will delete only row with 1200 value
- It will delete keep data with 1200 only
- None of these
- Which parameter is used to add in drop() method to delete columns?
- column = n (Where n is column number)
- col = n (Where n is column number)
- axis = 0
- axis = 1
Fill in the blanks:
- 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.
- Ms. Nimisha want to ignore last three rows from dataframe by using a slice with dataframe. So she will wirte _______ to do the same.
- 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.
- To delete rows using list of index as a parameter, _________ statement will be used.
- To delete rows and columns together, __________________ statement will be used.
Answers:
MCQs:
- 4. drop()
- 2. df.drop(‘Jay’)
- 3. df.drop(index=’T2′)
- 2. inplace = True
- 1. Delete row 1 and row 3
- It will delete only row with 1200 value
- axis = 1
Fill in the blanks:
- df[:3]
- df[:-3]
- df.drop(columns=[‘PhonNo’,’City’])
- df.drop(df.index[[0,1]]) –> To delete rows 0 & 1
- df.drop(index=df.index[[1,2]],columns=df.columns[1,2])
Descriptive Questions:
Office | Qtr1 | Qtr2 | Qtr3 | |
North | RO | 800 | 350 | 450 |
West | HO | 500 | 450 | 600 |
South | DO | 450 | 550 | 700 |
East | RO | 300 | 200 | 400 |
North | HO | 450 | 380 | 100 |
East | HO | 500 | 700 | 550 |
- What are the ways to delete rows using drop() method?
- To delete rows using drop() method do the following:
- By index name or multiple indices
- By index name with inplace
- By .index attribute
- != relational operator
- To delete rows using drop() method do the following:
- What are the ways to delete rows/columns without using drop() method?
- del keyword
- pop() function
- loc/iloc
- What are the ways to delete columns using drop() method?
- Using column labels
- multiple columna names
- passing columns parameter in drop()
- column index list
- Consider above dataframe and write statement to
- Delete rows with labels East and West.
- df=df.drop([‘East’,’West’])
- df.drop([‘East’,’West’],inplace=True)
- df=df.drop(df.index[[3,4]])
- Delete columns Office and Qtr3
- df.drop([‘Office’,’Qtr3′],axis=1)
- df.drop(columns=[‘Office’,’Qtr3′])
- df.drop(df.coloumns[[0,3]],axis=1)
- Delete rows with labels East and West.
- Correct errors in the following statements:
- df.delete([‘north’,’south’])
- df.drop([‘north’,’south’])
- df.drop(index.delete=”North”)
- df.drop(df.index=’North’)
- df=df.drop([“North”,”South”],axis=1)
- df=df.drop([‘North’,’South’],axis=0)
- df.drop(Qtr1,Qtr2)
- df=df.drop([‘Qtr1′[‘Qtr2’],axis=1)
- df.drop(df.iloc[‘North’,’Qrt1′])
- df=df.drop(df.iloc[0].name)
- df.drop(df.loc[0][‘Qtr4’])
- df=df.drop(df.loc[:,[‘Qtr4’]],axis=1)
- df.drop(df.index[[‘North’,’West’]])
- df=df.drop(df.index[[0,1]])
- df.drop(df!office[‘HO’])
- print(df[df.office!=’HO’])
- df.delete([‘north’,’south’])
Just have look on the notes prepared for delete row columns pandas questions.
I hope these questions will help you in preparing for your exams for dataframe delete and drop command. Thank you for reading this article delete row columns pandas questions.
Hit the like button and share this article delete row columns pandas questions with your friends. So learn more!
Feel free to ask any queries or doubts in the comment section.