Python Practice › Pandas Programs › Program 64
All columns except one
Write a pandas program to select all columns except one.
Output
name salary 0 Alex 50000 1 John 65000
Approach
drop(columns=...).
Solution
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John"], "age": [30, 27], "salary": [50000, 65000]})print(df.drop(columns="age"))Output
name salary 0 Alex 50000 1 John 65000
Learn the concept
New to this topic? Read the lesson, then come back.