Skip to main content
added 91 characters in body
Source Link
ccpizza
  • 32.4k
  • 24
  • 186
  • 195

If your original dataframe df is not too big, you have no memory constraints, and you only need to keep a few columns, or, if you don't know beforehand the names of all the extra columns that you do not need, then you might as well create a new dataframe with only the columns you need:

new_df = df[['spam', 'sausage']] 

If your original dataframe df is not too big, you have no memory constraints, and you only need to keep a few columns then you might as well create a new dataframe with only the columns you need:

new_df = df[['spam', 'sausage']] 

If your original dataframe df is not too big, you have no memory constraints, and you only need to keep a few columns, or, if you don't know beforehand the names of all the extra columns that you do not need, then you might as well create a new dataframe with only the columns you need:

new_df = df[['spam', 'sausage']] 
Source Link
ccpizza
  • 32.4k
  • 24
  • 186
  • 195

If your original dataframe df is not too big, you have no memory constraints, and you only need to keep a few columns then you might as well create a new dataframe with only the columns you need:

new_df = df[['spam', 'sausage']]