Feature Engineering in Python
Create new meaningful columns from existing data — skills that increase your analytical value
Feature engineering is creating new columns (features) from existing data that are more useful for analysis or modelling. Examples: calculating profit margin from revenue and cost, extracting month from a date, creating age buckets from age numbers, flagging high-value customers.
This skill is what differentiates a data analyst who just runs aggregations from one who adds analytical insight. Every meaningful KPI you add to a dashboard is a form of feature engineering.
Example
Key Points
- ✓pd.cut() creates equal-width bins; pd.qcut() creates equal-frequency bins (quartiles)
- ✓Date features (month, day of week, quarter) are some of the most valuable engineered features
- ✓Ratio features (margin %, discount rate) often reveal more than raw numbers
- ✓Group-level aggregates merged back to the row level are powerful features
- ✓Feature engineering is iterative — domain knowledge guides which new features are meaningful
Practice Question
You want to split a continuous Age column into 4 equal-sized groups (same number of rows in each group). Which pandas function should you use?