Skip to main content
HomePython

Course

Reshaping Data with pandas

IntermediateSkill Level
4.7+
739 reviews
Updated 11/2024
Reshape DataFrames from a wide to long format, stack and unstack rows and columns, and wrangle multi-index DataFrames.
Start Course for Free
PythonData Manipulation4 hr15 videos52 Exercises4,450 XP23,867Statement of Accomplishment

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Loved by learners at thousands of companies

Group

Training 2 or more people?

Try DataCamp for Business

Course Description

Often data is in a human-readable format, but it’s not suitable for data analysis. This is where pandas can help—it’s a powerful tool for reshaping DataFrames into different formats. In this course, you’ll grow your data scientist and analyst skills as you learn how to wrangle string columns and nested data contained in a DataFrame. You’ll work with real-world data, including FIFA player ratings, book reviews, and churn analysis data, as you learn how to reshape a DataFrame from wide to long format, stack and unstack rows and columns, and get descriptive statistics of a multi-index DataFrame.

Prerequisites

Data Manipulation with pandas
1

Introduction to Data Reshaping

Let's start by understanding the concept of wide and long formats and the advantages of using each of them. You’ll then learn how to pivot data from long to a wide format, and get summary statistics from a large DataFrame.
Start Chapter
2

Converting Between Wide and Long Format

Master the technique of reshaping DataFrames from wide to long format. In this chapter, you'll learn how to use the melting method and wide to long function before discovering how to handle string columns by concatenating or splitting them.
Start Chapter
3

Stacking and Unstacking DataFrames

In this chapter, you’ll level-up your data manipulation skills using multi-level indexing. You'll learn how to reshape DataFrames by rearranging levels of the row indexes to the column axis, or vice versa. You'll also gain the skills you need to handle missing data generated in the stacking and unstacking processes.
Start Chapter
4

Advanced Reshaping

Reshaping Data with pandas
Course
Complete

Earn Statement of Accomplishment

Add this credential to your LinkedIn profile, resume, or CV
Share it on social media and in your performance review
Enroll Now

Don’t just take our word for it

*4.7
from 739 reviews
81%
17%
2%
0%
0%
  • Md. Naimul
    2 days ago

    its very standard course

  • Mateusz
    3 days ago

  • Jerry
    4 days ago

  • NADIFA
    5 days ago

  • Shiraz
    last week

  • willy
    last week

Mateusz

Jerry

NADIFA

FAQs

What pandas skills should I have before starting this course?

You should be comfortable with basic pandas operations from Data Manipulation with pandas and Intermediate Python, including working with DataFrames, filtering, and grouping.

What is the difference between wide and long data formats covered in this course?

Wide format has one row per observation with variables in columns, while long format stacks variables into rows. You will learn to convert between them using pivot, melt, and wide_to_long.

What real-world datasets will I work with?

You will practice with FIFA player ratings, book reviews, and churn analysis data to reshape, stack, and unstack DataFrames in realistic scenarios.

Does this course cover handling nested JSON data?

Yes. The final chapter teaches you how to transform list-like columns and handle complex nested data, including nested JSON files, using pandas reshaping techniques.

What will I be able to do after completing this course?

You will be able to pivot, melt, stack, and unstack DataFrames, work with multi-level indexes, and reshape nested or list-like data for analysis-ready formats.

Join over 19 million learners and start Reshaping Data with pandas today!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Grow your data skills with DataCamp for Mobile

Make progress on the go with our mobile courses and daily 5-minute coding challenges.