Transformation for Python for Data Analysiss
Transformation means reshaping a cleaned DataFrame into the form a question needs, using groupby aggregation, pivots, melts, joins and time-series resampling. It follows basic cleaning in pandas and comes before exploration, because summaries by customer, product or month usually require the data to be regrouped first.
Stage: Analysis · Part of the Python for Data Analysis roadmap · Last reviewed 19 November 2026
What to learn in Transformation
- Aggregate with groupby and named aggregations for several statistics at once
- Reshape between wide and long layouts with pivot_table and melt
- Combine tables using merge types and explain inner versus left joins
- Parse dates and index a DataFrame by time
- Resample daily data to weekly or monthly totals
- Compute rolling averages and period-over-period changes
Transformation interview questions
When would you use pivot_table instead of groupby?
groupby aggregates and returns a long result indexed by the keys. pivot_table does the same aggregation but spreads one key across columns, giving a cross-tab layout. Use it when you want a readable grid, such as sales by region and month.
What does resample do on a time-indexed DataFrame?
resample groups rows into regular time buckets, such as W for weekly or M for monthly, based on the DatetimeIndex. You then apply an aggregation like sum or mean. It is groupby for time, and it can also fill gaps when upsampling.
Where Transformation fits in the Python for Data Analysis roadmap
Transformation belongs to the Analysis stage (beginner level), which takes about 27 hours. Explore and transform.
Other units in this stage
Back to the full Python for Data Analysis roadmap