Dropping columns

To drop columns, you can use pandas' drop() function. It takes a single column as well as a list of columns, and in this example, additional optional arguments indicate which is the axis along which to drop and whether or not to drop columns in place:

df.drop(['col1','col2'], axis=1, inplace=True)
print(df)

The output is as follows:

  col3 new_col1  new_col2  new_col3  new_col4
0    x                  0         5         5
1    y                  0         7         7
2    z                  0         9         9
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset