Answers for "numerical and categorical columns and dataframes."

1

select categorical columns pandas

df_catagorical=df.select_dtypes(include=['category'])
Posted by: Guest on November-30-2021
1

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
Posted by: Guest on June-01-2020

Code answers related to "numerical and categorical columns and dataframes."

Python Answers by Framework

Browse Popular Code Answers by Language