Python Pandas - Main DataFrame, want to drop all columns in smaller DataFrame
Question: I have a DataFrame ('main') that has about 300 columns. I created a smaller
DataFrame ('public') and have been working on this.

I now want to delete the columns contained within 'public' from the larger
DataFrame ('main').

I've tried the following instructions:

<http://pandas.pydata.org/pandas-
docs/dev/generated/pandas.DataFrame.drop.html>

[Python Pandas - Deleting multiple series from a data frame in one
command](http://stackoverflow.com/questions/14363640/python-pandas-deleting-
multiple-series-from-a-data-frame-in-one-command)

without any success, along with various other statements that have been
unsuccessful.

The columns that make up 'public' are not consecutive - i.e. they are taken
from various points in the larger DataFrame 'main'. All of the columns have
the same Index. [Not sure if this is important, but 'public' was created using
the 'join' function].

Yes, I'm being lazy - I don't want to have to type out the names of every
column! I'm hoping there's a way to use the DataFrame 'public' in a statement
that will allow deletion of these columns en masse. If anyone has any
suggestions and/or guidance I'd be most grateful.

(Have Python 2.7 and am using Pandas, numpy, math, pylab etc.)

Thanks in advance.


Answer: Ignore my question - Murphy's Law prevails and I've just solved it.

I was using the statement from the stackoverflow question mentioned below:

    
    
    df.drop(df.columns[1:], axis=1) 
    

and this was not working. I have instead used

    
    
    df = df.drop(df2, axis=1)
    

and this worked (df = main, df2 = public). Simple really once you don't
overthink it.

