Answers for "drop all other columns except pandas"

2

pandas drop all columns except certain ones

df.drop(df.columns.difference(['a','b']), 1, inplace=True)
Posted by: Guest on December-02-2020
1

drop every other column pandas

#We would like to drop every other column
data = data.loc[:, np.arange(len(data.columns)) %2 == 0]
Posted by: Guest on September-05-2021

Code answers related to "drop all other columns except pandas"

Python Answers by Framework

Browse Popular Code Answers by Language