Encoding categorical variables means changing text labels into numbers so computers can understand them. We start with data that has categories like colors. We pick a method: label encoding or one-hot encoding. Label encoding changes each category to a number based on alphabetical order. For example, 'blue' becomes 0, 'green' 1, and 'red' 2. We add these numbers as a new column next to the original. This helps models use the data. One-hot encoding makes new columns for each category with 0 or 1 to show presence. This is better when categories have no order. The code example shows label encoding step by step, adding a new column with numbers. Remember, the original data stays the same unless you replace it. This process prepares categorical data for machine learning.