get categorical features pandas code example
Example 1: python dataframe get numeric columns
dfnew = df.select_dtypes(include=np.number)
Example 2: using df.astype to select categorical data and numerical data
df = pd.DataFrame({'vertebrates': ['Bird', 'Bird', 'Mammal', 'Fish', 'Amphibian', 'Reptile', 'Mammal']})
df.vertebrates.astype("category").cat.codes