Answers for "get categorical data into new dataframe"

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
0

how to store categorical variables in separate dataframe

df.loc[:,df.dtypes==np.object]
Posted by: Guest on March-22-2021

Code answers related to "get categorical data into new dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language