Pivot—The pivot() method

Learn how to apply various methods to pivot a DataFrame.

The pivot() method

While the long data format contains plenty of information stored in a simple structure, it’s challenging to summarize and analyze the many repeated rows of data directly.

We can use the pivot() method to convert data from a long to wide format. Suppose we have a long format dataset containing the yearly population (from 2010 to 2018) for the world’s top ten most populated countries, as displayed by the code below:

Get hands-on with 1400+ tech skills courses.