Тёмный

Python Pivot Tables Tutorial | Create Pandas Pivot Tables | Python Tutorial | Examples, Subtotals 

datagy
Подписаться 5 тыс.
Просмотров 44 тыс.
50% 1

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 148   
@OberynPinkViper
@OberynPinkViper 2 года назад
Just wanted to say thank you for the incredibly simple yet comprehensive video. I stumbled upon the pivot() method while working through data visualisation, and I wasn't 100% sure how it worked. After this watching this video, everything is much more clearer and understandable to me.
@datagy
@datagy 2 года назад
Thank you so much for your kind words! That means a lot!
@SoulSheIS
@SoulSheIS 3 года назад
Thank you for keeping your videos short, yet informative and engaging.
@datagy
@datagy 3 года назад
I’m glad you liked it!
@SoulSheIS
@SoulSheIS 3 года назад
@@datagy Absolutely! May I ask how would you know when to use the pivot method as oppose to the pivot_table method?
@datagy
@datagy 3 года назад
@@SoulSheIS the pivot_table method is a bit more flexible. Essentially, if you have duplicates in your data, the pivot_table method is necessary. Similarly, it allows you to use multiple indices. Historically, the pivot_table method is built on pivot, but was introduced to not break previous functionality. Hope this helps!
@SoulSheIS
@SoulSheIS 3 года назад
@@datagy Ah, okay, makes a lot of sense. Thank you for clarifying!
@datagy
@datagy 3 года назад
@@SoulSheIS Glad it helped!
@Danielmelian3
@Danielmelian3 2 года назад
I was looking for this everywhere, Thankyou so much!
@datagy
@datagy 2 года назад
Thanks so much, Daniel!
@SunGlassesBlue
@SunGlassesBlue Год назад
Thank you dude, you saved my life ! Subscribing is not an option =)
@datagy
@datagy Год назад
Glad it helped!
@SayanChakraborty10397
@SayanChakraborty10397 3 года назад
This was great! Thanks a lot :)
@datagy
@datagy 3 года назад
Thank you, Sayan!
@d00lph1n
@d00lph1n 3 года назад
Thank you. Great explanation :)
@datagy
@datagy 3 года назад
Thanks for your comment!
@ravirajshelar250
@ravirajshelar250 4 года назад
Thanks you just made me learn it so easily.😊
@datagy
@datagy 4 года назад
Thanks so much! I'm glad it was helpful!
@TrungNguyen-te1wm
@TrungNguyen-te1wm 3 года назад
Great tutorial. Thanks
@datagy
@datagy 3 года назад
Thanks Trung!
@jongcheulkim7284
@jongcheulkim7284 2 года назад
Thank you very much. This is very helpful.
@AdventuresOfChinchin
@AdventuresOfChinchin 3 года назад
I had searched Google and youtube for an entire day to gain some clarity in this concept. Finally got the right video. Thanks!
@datagy
@datagy 3 года назад
I’m so glad it was helpful!
@idlejam86
@idlejam86 3 года назад
same
@datagy
@datagy 3 года назад
Thank you so much!
@boppanibhanuprasad4612
@boppanibhanuprasad4612 3 года назад
Plain and simple.
@datagy
@datagy 3 года назад
Thank you!
@Diamond_Hanz
@Diamond_Hanz 3 года назад
NYC here...Data Science Major.
@datagy
@datagy 3 года назад
Welcome to the channel!
@amrimanel3855
@amrimanel3855 3 года назад
thank you very much for your explanation ; handsome man. do you have a document that contains all the equation please ? the links : all of them error
@datagy
@datagy 3 года назад
Thanks Amri! I'm glad it was helpful! I'm not able to find any formal documentation on this, but you can pass in many different kinds of functions, including numpy's functions.
@gauthamambethkar4483
@gauthamambethkar4483 3 года назад
The way you explained was perfect. Keep up the good work. Hoping to see a lot more data science and Machine Learning videos from you
@datagy
@datagy 3 года назад
Thanks so much, Gautham! I have lots more planned :)
@parthraval6052
@parthraval6052 3 года назад
hey nice video..one problem - suppose i have values in a column starting with 5555 eg(55551,55553,55557 etc)....how to filter it out
@datagy
@datagy 3 года назад
Hi Parth, Thanks for your comment! I'd say, and there's probably much better ways to do this, but one way you could do this is to filter a string version of the column: df = df[df['colname'].astype('str').str.contains('5555')]
@parthraval6052
@parthraval6052 3 года назад
@@datagy thanks for your reply I will try it out 👍
@XuanTran-ri1hn
@XuanTran-ri1hn 2 года назад
Thank you very much for your video. May I ask if you can explain the value in the pivot 5? Is it average value or sum? I just need a confirmation :)
@datagy
@datagy 2 года назад
Hi Xuan, thanks for your comment! By default, a Pandas pivot table will calculate the average value :).
@XuanTran-ri1hn
@XuanTran-ri1hn 2 года назад
@@datagy Thanks :)
@acesovernines
@acesovernines 9 месяцев назад
Succinct and super effective. Thank you so much
@datagy
@datagy 9 месяцев назад
Thanks so much!
@alcapone6796
@alcapone6796 3 года назад
How do I use the pivot table values to create a histogram?
@datagy
@datagy 3 года назад
You may not need to pivot anything to create the histogram, as the histogram will create bins for you automatically. I’d suggest checking out my video on histograms: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-m0y5uqU--YQ.html
@cocoapebbles10
@cocoapebbles10 3 года назад
This is awesome dude! You really saved my bacon here. It's so difficult to learn this stuff over Zoom class.
@datagy
@datagy 3 года назад
I'm so glad it was helpful!
@AnjanBasumatary
@AnjanBasumatary Год назад
How to display emty rows and column combination? ....in the output I only get those rows and column which have values
@datagy
@datagy Год назад
You can use dropna =False in the pivot_table function :)
@AnjanBasumatary
@AnjanBasumatary Год назад
@@datagy Table3TEST3= PL.pivot_table(values =( 'ID','IN'),index = 'SEGMENT', columns='CUTOFF',dropna= False, aggfunc = {'ID':'count','IN':sum}) I have used dropna=False but still not working files uploaded in this link: drive.google.com/drive/folders/1Pnc4YMjqL0loclfX-5Nxi3KTpxFd1ffm?usp=sharing
@yellowsun7241
@yellowsun7241 3 года назад
Thanks for this. How can I make jupyter print these nice looking tables like in the video ? Mine are very plain and all over the place. Cheers!
@datagy
@datagy 3 года назад
Thanks for your comment! It should work if you simply write the object name without calling print(). Hope this helps! :)
@yellowsun7241
@yellowsun7241 3 года назад
@@datagy thanks Nick! ;)
@Xiler6969
@Xiler6969 3 года назад
delete intro music
@ravindrareddy5478
@ravindrareddy5478 Год назад
is there any way to merge empty cells using python in a pivot table
@toddbrannon6262
@toddbrannon6262 2 года назад
Thanks for this video. So straight to the point. I learned something I can now put to use!
@datagy
@datagy 2 года назад
Thanks so much, Todd!
@DIGITAL_COOKING
@DIGITAL_COOKING 2 года назад
please i have one question if you want the mean values to be integers how you can do that, thanks!
@datagy
@datagy 2 года назад
You can convert the column to integers by apply the .astype('int') method on the column of the resulting dataframe :). Such as: pivot['col'] = pivot['col'].astype('int')
@DIGITAL_COOKING
@DIGITAL_COOKING 2 года назад
@@datagy thanks a lot for your help
@mapa5000
@mapa5000 3 года назад
Very well explained !!! . thank you !
@datagy
@datagy 3 года назад
Thanks so much, Marco!
@elfridhasman4181
@elfridhasman4181 2 года назад
Wow, thank you very much 🙏🙏😍
@datagy
@datagy 2 года назад
Thanks for your comment, Elfrid!
@syhusada1130
@syhusada1130 2 года назад
how would you pivot multiple columns?
@datagy
@datagy 2 года назад
If you’re looking to aggregate multiple columns, you could place them as a list into the values parameter :)
@deep.jain.
@deep.jain. Год назад
How to add filter to these pivot tables?
@datagy
@datagy Год назад
You’d filter the dataframe either beforehand or when you pass it into the data argument :)
@MayankSinghParmar
@MayankSinghParmar Год назад
Simple and Clear. Very good video
@datagy
@datagy Год назад
Thank you so much!
@alfonsoborges4885
@alfonsoborges4885 2 года назад
Thanks, great explanation !
@datagy
@datagy 2 года назад
Thanks for your comment!
@JDUDEadventure
@JDUDEadventure Год назад
Thank you video was super helpful to better understand pivot tables with pandas
@nicozing4552
@nicozing4552 3 года назад
Thank you so much! very clear :)
@datagy
@datagy 3 года назад
Thanks Nico!
@debjanidas6779
@debjanidas6779 2 года назад
Can you just tell me what and why you made changes between 7:39 sec to 7:42 sec. Than you great video
@azrflourish9032
@azrflourish9032 3 года назад
clear explanation! thank you
@datagy
@datagy 3 года назад
Thank you!
@hhbbhvvbjhbbyjj
@hhbbhvvbjhbbyjj 3 года назад
u couldnt of made the video more clear
@datagy
@datagy 3 года назад
Thanks so much!!
@דןשטיבלמן
@דןשטיבלמן Год назад
tnx alot. how can we claculate the precentage by the total (for each column....) ?
@MrFishingo
@MrFishingo 2 года назад
hello datagy!! two questions, how can I calculate a weighted average on the pivot table?? Second, after results are printed, how can I sort values within a column? thanks for the great videos!!
@datagy
@datagy 2 года назад
Hi Ricardo! Thanks so much for your comment! To sort your data, you'd technically want to sort it before printing it (or in the print function). You can sort data. Such as print(df.sort_values(by=['colname'])). I have a video on this topic here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-41XLTQI1qzI.html To create a weighted average you can follow along with my written tutorial here: datagy.io/pandas-weighted-average/ It'll walk you through a number of different ways in which you can calculate a weighted average (including using Pandas).
@ahmedhelal920
@ahmedhelal920 2 года назад
thanks for this useful information , i am trying to add pivot on function and add this function using xlwings on excel , the function works good , but i need it come with porders GUI instead off normal cells
@datagy
@datagy 2 года назад
Hi Ahmed, thanks for your comment! Could you explain what you mean by porders?
@timfairfield407
@timfairfield407 Год назад
great explanation. thanks
@datagy
@datagy Год назад
Thanks Tim!
@rohitbhosale3617
@rohitbhosale3617 Год назад
Thank you so much!To the point. Love from India
@milkway731
@milkway731 2 года назад
i just found if I set margin, the code will fail. Traceback (most recent call last)
@mariaromero3488
@mariaromero3488 Год назад
so helpful, thanks!
@datagy
@datagy Год назад
Thanks so much!
@chinmaychourdia6929
@chinmaychourdia6929 2 года назад
3:56 , What if we want only the region which has maximum sales
@AnalyticInsight
@AnalyticInsight 2 года назад
Thanks for your clear and complete treatment of pivot table. Easy to comprehend, started to use immediately.
@datagy
@datagy 2 года назад
Thanks so much for your comment! I appreciate the feedback :)
@SetoAjiNugroho
@SetoAjiNugroho 3 года назад
I skipped every basics of machine learning and now i realized that i need basic like this. Thanks to made it easy to learn. Very great explained :D
@datagy
@datagy 3 года назад
I’m so glad it was helpful! :)
@TotallyAqua
@TotallyAqua 3 года назад
Really helpful video. I liked how you explained adding totals to the rows and columns.
@datagy
@datagy 3 года назад
Thanks so much!
@syedrizvi2687
@syedrizvi2687 2 года назад
Thank you so much!
@datagy
@datagy 2 года назад
Thanks so much for your comment!
@mrescience2554
@mrescience2554 2 года назад
Oh my goodness, this is exactly what I needed! Great explanation, thank you so much.
@datagy
@datagy 2 года назад
Thank you so much! I’m glad it was helpful!
@86Maryj
@86Maryj 2 года назад
Hi can you pls to pivot with multiple sheets
@rajeeb101
@rajeeb101 2 года назад
Fantastic work! Simple and to the point. Thank you.
@datagy
@datagy 2 года назад
Thank you so much!
@tuandino6990
@tuandino6990 2 года назад
well explained!
@datagy
@datagy 2 года назад
Thank you!!
@rferstahl
@rferstahl 2 года назад
simple and to the point, exactly what I was looking for. Thanks
@datagy
@datagy 2 года назад
I’m so glad!
@MagnusAnand
@MagnusAnand 3 года назад
Cool video
@datagy
@datagy 3 года назад
Thanks Guz!
@vicka_zhurina
@vicka_zhurina 3 года назад
Nik, thank you for such a clear explanation of the syntax and all the features! It’s not the first of your videos that I have seen, and each time I am amazed how simply Python might be clarified. Good luck and a lot of inspiration for your new videos!
@datagy
@datagy 3 года назад
Thank you so much for your kind words! I’ll have more videos coming soon! :)
@ShawVishal
@ShawVishal 3 года назад
Thanks
@datagy
@datagy 3 года назад
You’re welcome!
@krishnaRaog21
@krishnaRaog21 3 года назад
Very nice ...You made things so simple
@datagy
@datagy 3 года назад
Thanks! I’m glad you liked it!
@luqmanhakim7781
@luqmanhakim7781 4 года назад
Crystal clear explanation ! Thanks for sharing.. looking forward for more content like this :)
@datagy
@datagy 4 года назад
Thank you so much Luqman! I’ll be releasing more videos soon! :)
@luqmanhakim7781
@luqmanhakim7781 4 года назад
@@datagy keep it up the good work man 👍
@DrSpacemann
@DrSpacemann 4 года назад
Killed it again! Very clear and easy to follow,thank you!
@datagy
@datagy 4 года назад
Thanks so much! 😊
@tobecontinued...5712
@tobecontinued...5712 3 года назад
What if the value i want its sum is a string?? what can i do to get the sum of a string value?
@datagy
@datagy 3 года назад
Hi there! Is the "string" a number? i.e., "9" formatted as a string?
@tobecontinued...5712
@tobecontinued...5712 3 года назад
@@datagy no ,the value is " lancé, terminé, provisoire ", and i have different section, and I want the sum of the values of each section.
@datagy
@datagy 3 года назад
@@tobecontinued...5712 Ah, you want the values broken out by those categories? So each section lance, termine, provisoire (forgive my lack of accents) would have numeric values beside it?
@coachjeffnac
@coachjeffnac 3 года назад
I normally get my info on youtube videos and go. This video quickly/easily helped me solve something I'd been struggling with! I had a groupby that I couldn't figure out how to transpose. PIVOT is what I wanted! Thanks!
@datagy
@datagy 3 года назад
I’m glad it helped! :)
@irvingescobar3977
@irvingescobar3977 4 года назад
This is exactly the video I needed! Been looking to transition out of excel pivots due to huge data sets and this was super helpful.
@datagy
@datagy 4 года назад
I’m so glad it was helpful, Irving!
@irvingescobar3977
@irvingescobar3977 4 года назад
@@datagy Hoping you do some more deep dives into data analysis soon :D
@datagy
@datagy 4 года назад
Thanks!! I’ve got a lot of exciting stuff coming!
@Dimejesi
@Dimejesi Год назад
Thank you so much. I just started learning python for data Science and you really broke this down and made it easy for me to understand
@datagy
@datagy Год назад
Thank you!! That means a lot to me!
@kinanradaideh5479
@kinanradaideh5479 Год назад
@6:21
@seekthehorizon6854
@seekthehorizon6854 2 года назад
😅😊
@jamesgilmore5538
@jamesgilmore5538 2 года назад
This was the most helpful video I've seen on anything pandas. Thank you. Appreciate the simple and short examples/steps that explain the arguments.
@datagy
@datagy 2 года назад
Thanks so much, James! That means a lot to me!
@gouthamkarakavalasa4267
@gouthamkarakavalasa4267 3 года назад
Hi can you pls let me know how to create pivot tables with mode as function, no mean. I looking a way to analyse data by pivoting on object data type with mode function. Kindly do the needful.
@datagy
@datagy 3 года назад
Hi there! Thanks so much for your great question! Import mode from scipy.stats using: from scipy.stats import mode Then, in your pivot table, as the aggfunc= use the following: aggfunc=lambda x: x.mode().iat[0] Just tested it and it works well :)
@gouthamkarakavalasa4267
@gouthamkarakavalasa4267 3 года назад
@@datagy Hey, Thank u very much.. it worked:)
@datagy
@datagy 3 года назад
I’m so glad! Thanks for letting me know :)
@bevg1
@bevg1 2 года назад
wow! you are a good teacher... straight to the point and it is not boring. 👍
@datagy
@datagy 2 года назад
Thank you so much!
@gvvlogsriderunrefresh6155
@gvvlogsriderunrefresh6155 3 года назад
One of the best videos i have ever seen. So simplified and So effective
@datagy
@datagy 3 года назад
Thank you, Gaurav!
@gvvlogsriderunrefresh6155
@gvvlogsriderunrefresh6155 3 года назад
@@datagy Hey Nik , Can you also put in some videos on Seaborn usage for Visualization and on Statistics in Python. It will be a great favour brother
@datagy
@datagy 3 года назад
Hey Gaurav! Seaborn is definitely planned (as well as plotly). What kind of statistics in python are you looking for? :) thanks for the ideas!
@gvvlogsriderunrefresh6155
@gvvlogsriderunrefresh6155 3 года назад
Dear Nik, In statistics if you can cover working with scipy.stats , cover some tests in python etc . Thanks a lot again for your prompt response
@datagy
@datagy 3 года назад
@@gvvlogsriderunrefresh6155 Thanks! I'll add this to the list!
Далее
How do I use the MultiIndex in pandas?
25:01
Просмотров 174 тыс.
Pivot tables with Pandas
9:00
Просмотров 40 тыс.
Make Your Pandas Code Lightning Fast
10:38
Просмотров 184 тыс.
Stack, Unstack, Melt, Pivot - Pandas
10:23
Просмотров 39 тыс.