Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. columns_to_retain = 'name, sex, age' # a string of columns
  2. # which will not be dropped
  3. # from the dataframe
  4. x_cols = columns_to_retain.split(',')
  5.  
  6. new_df = df.drop(columns = not x_cols)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement