How to drop multiple columns in python?
In python, we have data of many columns and rows. And we want to show only some columns off that data. Then what will we do.
We have a drop() function which help in dropping columns in the data.
e.g.,
import pandas as pd data = { 'A':['1', '2', '3', '4', '5'], 'B':['1', '2', '3', '4', '5'], 'C':['1', '2', '3', '4', '5'], 'D':['1', '2', '3', '4', '5'], 'E':['1', '2', '3', '4', '5'] } df = pd.DataFrame(data) print(df) df.drop(['A','C'], axis = 1) print(df)
This is how we can drop columns in python.
Subscribe
Login
Please login to comment
0 Discussion