Convenient Methods to Encode Categorical Variables in Python

Easy and flexible methods to encode string variables for further quantitative analysis

Dr. Shouke Wei
6 min readNov 12, 2022

In many cases, we need to transfer categorical or string variables into numbers in order to analyze the data quantitatively or develop a model. There are many different methods to do that. In this article, I will show you some easy but practical methods to encode columns with categorical data or strings into numerical values.

This article is the Part VII of Data Analysis Series, which includes the following parts. I suggest you read from the first part so that you can better understand the whole process.

--

--

Dr. Shouke Wei

Professor and Scientist in data analysis and modelling, machine learnig, and computer vision. Support my writing: https://medium.com/@shouke.wei/membership