Closed
Description
Current dataframe.drop will raise error for below code for 'non_exist_in_df_col' :
df = df.drop(['col_1', 'col_2', 'non_exist_in_df_col'], axis=1)
But below is better for it can accept it.
def drop_cols(df, del_cols):
for col in (set(del_cols) & set(df.columns)):
df = df.drop([col], axis=1)
return df
DataFrame.drop_cols = drop_cols
And it will be better to add an 'inplace' option to speed up the repeatly df self-assignment.