Below I’ve posted my code to find out how df.pivot() method works. This is related to Transforming Data With Pandas. This project was exciting and kind of crazy because I wished to create an answer that will unfold from the whole Transforming Data With Pandas lesson. Because the additional task about finding out how
df.pivot() method works was the last step of this lesson, I desired to add all preceding steps to the code. Why? Well, I thought that maybe it will be cool to have all things in one place, what’s more, I could use some objects from this lesson in the final
I thought it will take maybe a few hours and will be done. I was so wrong! It was so because when I’ve started to create this code, almost immediately another problem arises. An old problem that bothers me almost from the beginning of my learning: when someone wants to see the code without downloading it: no pictures are displayed. Fixing that took me 3 weeks.
Full code below:
About the df.pivot(). I don’t understand one thing. The object created with df.pivot() is a dataframe, but when it includes two columns I can’t choose in any way to display single cell, or row slice. All I can do is posted below. I don’t know why it is so.
why this doesn’t works ? :