Answers for "how drop column pandas"

85

drop a column pandas

df.drop(['column_1', 'Column_2'], axis = 1, inplace = True)
Posted by: Guest on November-08-2020
-1

drop dataframe columns

# Drop The Original Categorical Columns which had Whitespace Issues in their values
df.drop(cat_columns, axis = 1, inplace = True)

dict_1 = {'workclass_stripped':'workclass', 'education_stripped':'education', 
         'marital-status_stripped':'marital_status', 'occupation_stripped':'occupation',
         'relationship_stripped':'relationship', 'race_stripped':'race',
         'sex_stripped':'sex', 'native-country_stripped':'native-country',
         'Income_stripped':'Income'}

df.rename(columns = dict_1, inplace = True)
df
Posted by: Guest on April-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language