SHARE
TWEET

Untitled

a guest Jun 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top