Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python how to drop columns from dataframe

# When you have many columns, and only want to keep a few:
# drop columns which are not needed.

# df = pandas.Dataframe()
columnsToKeep = ['column_1', 'column_13', 'column_99']
df_subset = df[columnsToKeep]

# Or:
df = df[columnsToKeep]
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #python #drop #columns #dataframe
ADD COMMENT
Topic
Name
8+6 =