Let's Think About This for a Second
Feature Engineering means creating or selecting new features from raw data that help the model perform better — following the 'garbage in, garbage out' principle, no matter how sophisticated your algorithm is, it can't perform well without good features. Categorical Encoding converts text categories (e.g. 'red', 'blue', 'green') into numbers — One-Hot Encoding (creating a separate binary column for each category) is the most commonly used method. Feature Selection means removing irrelevant or redundant features (to reduce noise and speed up the model).
Connecting to a Real Scenario
Instead of using the 'purchase_date' column directly as a feature in house data, engineering a new feature like 'house_age' (current_year - built_year) can be much more helpful to the model — running `pd.get_dummies(df['neighborhood'])` converts the categorical 'neighborhood' column into multiple binary columns (neighborhood_A, neighborhood_B, ...) via One-Hot Encoding.
Let's Look at It Together
import pandas as pd
# Feature engineering: derive house_age from built_year
df['house_age'] = 2026 - df['built_year']
# One-hot encode a categorical column
df_encoded = pd.get_dummies(df, columns=['neighborhood'])
print(df_encoded.columns.tolist())['size', 'built_year', 'price', 'house_age', 'neighborhood_A', 'neighborhood_B', 'neighborhood_C']Try It in 5 Minutes
Create a sample dataset yourself (with one categorical column and one date column), and run both feature engineering (deriving age) and One-Hot Encoding on it.
A Quick Word of Caution
Don't do feature engineering in a way that leaks test data (e.g. creating a feature from the average of the entire dataset — this can indirectly leak information from the test data) — you should derive statistics from the training data only and then apply them to the test data.