Stack, Unstack, Melt, Pivot - Pandas

preview_player
Показать описание
“There should be one—and preferably only one—obvious way to do it,” — Zen of Python. I certainly wish that were the case with pandas. In reading the docs it feels like there are a thousand ways to do each operation. And it is hard to tell if they do the exact same thing or which one you should use. That's why I made An Opinionated Guide to pandas—to present you one consistent (and a bit opinionated) way of doing data science with pandas and cut out all the confusion and cruft.

I'll talk about which methods I use, why I use them and most importantly tell you the stuff that I've never touched in my years of data science practice. If this sounds helpful to you then please watch and provide feedback in your comments.

This series is beginner-friendly but aimed most directly at intermediate users.

“Opinionated Guide – Group Operations” contents:
Helpful links:

Рекомендации по теме
Комментарии
Автор

Started my analytics journey as a way to upskill during the pandemic. It has not been easy. However, the journey has been worth it. For those who are just starting out, stick with it!! Things will begin to click. Be patient and it’ll come!

barefootalex
Автор

Lecture notes - Stack, Unstack, Melt, Pivot
1. stack, unstack - moving things from 'columns into the indices' and 'the indices back into the columns'
(useful when you need to deal with pivot table format)
2. melt, pivot - fancy way for stacking and unstacking
3. get_dummies() - for Meachine Learning

arhataria
Автор

Thanks for your Video !
Can you please let me know if we can put those collapse and expand functionality in actually generated pivot table in excel using python ??

automatewithamit
Автор

Awesome video and tutorial. One caveat I would add about pd.get_dummies() and using it in preparation for any type of linear models (at 8:50) is that you would need to drop either the sex_Male or sex_Female columns so as to avoid the dummy variable trap.

DookyButter
Автор

How to display emty rows and column combination in pivot table function ? ....in the output I only get those rows and column which have values

AnjanBasumatary
Автор

Cool stuff Nathaniel! I use stacking/unstacking over melt too for quite similar reasons

pranay
Автор

DUDE YOURE A BLESSING! THANKS FOR THIS!

vinceangeloespada
Автор

Phenomenal video and had no idea about the creation of the dummy variables.

ericwr
Автор

I don't need multi-index functionality of pandas. So I stick to pivot/melt rather than stack/unstack.
btw. great quality of videos.

moongihong
Автор

I like the explanation. I've been using melt, though I'll start looking into stack/unstack. Is there an advantage of one over the other (stack vs. melt)?

eatcake
Автор

Very nice video! I have two simple problems if you have a video about it would be nice!
1- I have multiple values in the same cell, so I have to split the value and create multiple columns and than stack() - How to split the values from one cell?
2- I have values in one column that if it is a one I want to select that line to check if the value of the second column exist or not, and if does count it.

dr.kingschultz
Автор

The problem I had with stack() was that I was not able to use the stacked data in DataFrame structure.. melt() saved me though!

jessyjames
Автор

Great content, and I really like your voice!

riley
Автор

Hi how to pivot multiple columns? For example I have 9 columns and I want to retain columns 1 to 3 and pivot the columns from 4 to 9.

marlonmag-isa
Автор

I only have 1 column that is in number in value. And I want to stack it groupby that column.
columns: house_number, zone, full_name, occupation


Can I stack by the house_number by using groupby?
and How can I do that?

imotivate
Автор

3:00 unstack mark can do the thing you're lookin to do

jordanhensiek
join shbcf.ru