I am trying to drop columns from a dataframe but not working.
columns_to_retain = 'name, sex, age'    # a string of columns 
                                        # which will not be dropped 
                                        # from the dataframe
x_cols = columns_to_retain.split(',') 
new_df = df.drop(columns = not x_cols)  
The new_df should retain the data and columns name, sex and age.
 
     
    