Convert categorical data in pandas dataframe
First, to convert a Categorical column to its numerical codes, you can do this easier with: dataframe[‘c’].cat.codes.Further, it is possible to select automatically all columns with a certain dtype in a dataframe using select_dtypes. This way, you can apply above operation on multiple and automatically selected columns. First making an example dataframe: Then by using select_dtypes to select the … Read more