Find categorical and continuous columns in a dataframe

Thought I will share an easy way to separate continuous and categorical column names from a dataframe to feed into the tabular_learner function.

If you do df.describe().columns you will get the list of all continuous columns, where df is your dataframe.

Then, if you do list(set(df.columns) - set(df.describe().columns)) you will get the categorical columns.

Easy!

1 Like