1df.drop(df.index[-2])
2df.drop(df.index[[3, 4]])
3df.drop(['row_1', 'row_2'])
4df.drop('column_1', axis=1)
5df[df.name != 'cell']
1df = df.drop(df.columns[[0, 1, 3]], axis=1) # df.columns is zero-based pd.Index
1>>> df
2 A B C D
30 0 1 2 3
41 4 5 6 7
52 8 9 10 11
6
7Drop a row by index
8
9 df.drop([0, 1])
10 A B C D
11 2 8 9 10 11
12
13Drop columns
14
15 df.drop(columns=['B', 'C'])
16 A D
17 0 0 3
18 1 4 7
19 2 8 11
1# importing pandas module
2import pandas as pd
3
4# making data frame from csv file
5data = pd.read_csv("nba.csv", index_col ="Name" )
6
7# dropping passed values
8data.drop(["Avery Bradley", "John Holland", "R.J. Hunter",
9 "R.J. Hunter"], inplace = True)
10
11# display
12data
13