Retrieve DataFrame of all but one specified column [duplicate]

Is there a way to select all but one column in a pandas DataFrame object? I've seen ways to delete a column, but I don't want to do that.


Solution 1:

use drop method:

df.drop(column_name, axis=1)

Solution 2:

df.loc[:, df.columns != col]

where col is the name of the column to leave out.