pandas drop all columns except certain ones

Solutions on MaxInterview for pandas drop all columns except certain ones by the best coders in the world

showing results for - "pandas drop all columns except certain ones"
Mateo
08 Apr 2016
1df.drop(df.columns.difference(['a','b']), 1, inplace=True)
queries leading to this page
drop all columns except in pandaspandas df drop all columns exceptdataframe drop all columns 2bexcept 1python pandas drop all columns exceptpandas delete all columns excepthow to drop all the columns except one column in a dataframeremove columns from dataframe pandas except somehow to drop all columns except one in pandasdelete all columns except pandasdf drop all columns exceptpd drop all columns excepthow to drop all the columns from a dataframe except the selected one 27s in pythondataframe drop all except columnsdrop all columns in dataframe exceptdelete all columns except one in pandaspyhton pandas delete all columns except a fewhow to drop all columns except two in pandaspandas drop all columns except lastdataframe remove all columns exceptpandas drop all columns except certain onesdrop all other columns except pandasdrop all except some column pandaspython pandas delete all columns except specificeddrop all but a few columns pandasdataframe drop all columns except onepandas remove all columns exceptdrop all column except first columns pythondrop all columns except selected ones in pythinpandas remove all rows with columns exceptpandas dataframe drop all columns exceptpandas dataframe remove all columns except 2how to drop all columns in panda except onedrop all columns except one pandasdrop columns except pandaspython pandas drop all columns except onehow to delete all columns except one in pandasdf remove all columns exceptdrop all columns except some list pandasdataframe drop all columns exceptdrop all columns except pandaspython delete all lines dataframe excephow to drop all columns expect one pandasremove all columns except defined friom dataframephyton drop all exceptpandas how to drop all columns excepthow to drop all columns in pandas excpt a fewpython drop if all columns are 0delete alla columns of a dataframe exept of onedataframe drop all except 2 columnsremove all strings from columns except pandasdataframe drop columns exceptdrop all columns except list of columns pandaspandas drop every column exceptremove all columns except pandasdrop columns pandas exceptpandas drop all columns except twohow to drop all columns except fewdrop all columns except two pandasdrop all except 3 column pandasdelete all column except some columns pandaspandas df drop all cols except onedf drop columns except specificdataframe drop all columns except 1dataframe drop column exceptpandas delete columns exceptdrop all except 2 column pandaspython pandas delete columns exceptpandas drop columns except fordrop all columns excepthow to drop all columns except a few in pandaspandas drop all columns exceptpandas drop all columns except certain ones