janitor.remove_columns

janitor.remove_columns(df: pandas.core.frame.DataFrame, column_names: Union[str, Iterable[str], Hashable]) → pandas.core.frame.DataFrame[source]

Remove the set of columns specified in column_names.

This method does not mutate the original DataFrame.

Intended to be the method-chaining alternative to del df[col].

Method chaining syntax:

df = pd.DataFrame(...).remove_columns(column_names=['col1', 'col2'])
Parameters:
  • df – A pandas DataFrame
  • column_names – The columns to remove.
Returns:

A pandas DataFrame.