I have a list of column names from a dataframe and would like to generate a second list of column names that excludes everything in that first list.
I was thinking something like features=x[~x[exclude_features]].columns
(where exclude_features is a list of column names to exclude, but that throws an error. Thanks for the help!
Let us try
features=x.loc[:, ~x.columns.isin(exclude_features)].copy()
Or
features=x.loc[:, x.columns.difference(exclude_features)].copy()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With