Unpivoting a Pandas DataFrame

How to massage a Pandas DataFrame into the shape you need

Dean McGrath
Towards Data Science
3 min readJan 29, 2021

--

Photo by Todd Quackenbush on Unsplash

Introduction

Last article we shared an embarrassing moment which encouraged us to learn and use Pandas to pivot a DataFrame. Today we are going to look at Pandas built-it .melt() function to reverse our pivoted data. The .melt() function comes in handy when you need to reshape or…

--

--