Pandas: Converting Categorical Columns to Numerical #datascience #python #pandas #machinelearning

preview_player
Показать описание
In this short, I show you a function I wrote to prepare pandas data frames for machine learning models.

Here's the function:

def cat2num(dataframe):
if dataframe[column].dtype == 'object':
dataframe[column] = pd.Categorical(dataframe[column]).codes
return dataframe
Рекомендации по теме