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

  Рет қаралды 44,339

datagy

datagy

Күн бұрын

Пікірлер: 148
@amethystmind
@amethystmind 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!
@SunGlassesBlue
@SunGlassesBlue 2 жыл бұрын
Thank you dude, you saved my life ! Subscribing is not an option =)
@datagy
@datagy 2 жыл бұрын
Glad it helped!
@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 4 жыл бұрын
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 4 жыл бұрын
I’m so glad it was helpful! :)
@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!
@OberynPinkViper
@OberynPinkViper 3 жыл бұрын
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 3 жыл бұрын
Thank you so much for your kind words! That means a lot!
@amahimahiaha
@amahimahiaha 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! :)
@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 :)
@TotallyAqua
@TotallyAqua 3 жыл бұрын
Really helpful video. I liked how you explained adding totals to the rows and columns.
@datagy
@datagy 3 жыл бұрын
Thanks so much!
@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!
@Danielmelian3
@Danielmelian3 2 жыл бұрын
I was looking for this everywhere, Thankyou so much!
@datagy
@datagy 2 жыл бұрын
Thanks so much, Daniel!
@rajeeb101
@rajeeb101 2 жыл бұрын
Fantastic work! Simple and to the point. Thank you.
@datagy
@datagy 2 жыл бұрын
Thank you so much!
@Dimejesi
@Dimejesi 2 жыл бұрын
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 2 жыл бұрын
Thank you!! That means a lot to me!
@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!
@rferstahl
@rferstahl 2 жыл бұрын
simple and to the point, exactly what I was looking for. Thanks
@datagy
@datagy 2 жыл бұрын
I’m so glad!
@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! :)
@MayankSinghParmar
@MayankSinghParmar 2 жыл бұрын
Simple and Clear. Very good video
@datagy
@datagy 2 жыл бұрын
Thank you so much!
@rohitbhosale3617
@rohitbhosale3617 2 жыл бұрын
Thank you so much!To the point. Love from India
@toddbrannon6262
@toddbrannon6262 3 жыл бұрын
Thanks for this video. So straight to the point. I learned something I can now put to use!
@datagy
@datagy 3 жыл бұрын
Thanks so much, Todd!
@JDUDEadventure
@JDUDEadventure Жыл бұрын
Thank you video was super helpful to better understand pivot tables with pandas
@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!
@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!
@DrSpacemann
@DrSpacemann 4 жыл бұрын
Killed it again! Very clear and easy to follow,thank you!
@datagy
@datagy 4 жыл бұрын
Thanks so much! 😊
@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!
@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 👍
@mrescience2554
@mrescience2554 3 жыл бұрын
Oh my goodness, this is exactly what I needed! Great explanation, thank you so much.
@datagy
@datagy 3 жыл бұрын
Thank you so much! I’m glad it was helpful!
@mapa5000
@mapa5000 3 жыл бұрын
Very well explained !!! . thank you !
@datagy
@datagy 3 жыл бұрын
Thanks so much, Marco!
@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 :)
@alfonsoborges4885
@alfonsoborges4885 2 жыл бұрын
Thanks, great explanation !
@datagy
@datagy 2 жыл бұрын
Thanks for your comment!
@acesovernines
@acesovernines Жыл бұрын
Succinct and super effective. Thank you so much
@datagy
@datagy Жыл бұрын
Thanks so much!
@d00lph1n
@d00lph1n 3 жыл бұрын
Thank you. Great explanation :)
@ravirajshelar250
@ravirajshelar250 4 жыл бұрын
Thanks you just made me learn it so easily.😊
@datagy
@datagy 4 жыл бұрын
Thanks so much! I'm glad it was helpful!
@krishnaRaog21
@krishnaRaog21 4 жыл бұрын
Very nice ...You made things so simple
@datagy
@datagy 4 жыл бұрын
Thanks! I’m glad you liked it!
@SayanChakraborty10397
@SayanChakraborty10397 3 жыл бұрын
This was great! Thanks a lot :)
@datagy
@datagy 3 жыл бұрын
Thank you, Sayan!
@jongcheulkim7284
@jongcheulkim7284 2 жыл бұрын
Thank you very much. This is very helpful.
@azrflourish9032
@azrflourish9032 3 жыл бұрын
clear explanation! thank you
@datagy
@datagy 3 жыл бұрын
Thank you!
@דןשטיבלמן
@דןשטיבלמן 2 жыл бұрын
tnx alot. how can we claculate the precentage by the total (for each column....) ?
@TrungNguyen-te1wm
@TrungNguyen-te1wm 3 жыл бұрын
Great tutorial. Thanks
@datagy
@datagy 3 жыл бұрын
Thanks Trung!
@chinmaychourdia6929
@chinmaychourdia6929 2 жыл бұрын
3:56 , What if we want only the region which has maximum sales
@nicozing4552
@nicozing4552 3 жыл бұрын
Thank you so much! very clear :)
@datagy
@datagy 3 жыл бұрын
Thanks Nico!
@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
@timfairfield407
@timfairfield407 2 жыл бұрын
great explanation. thanks
@datagy
@datagy 2 жыл бұрын
Thanks Tim!
@ravindrareddy5478
@ravindrareddy5478 Жыл бұрын
is there any way to merge empty cells using python in a pivot table
@mariaromero3488
@mariaromero3488 Жыл бұрын
so helpful, thanks!
@datagy
@datagy Жыл бұрын
Thanks so much!
@AnjanBasumatary
@AnjanBasumatary 2 жыл бұрын
How to display emty rows and column combination? ....in the output I only get those rows and column which have values
@datagy
@datagy 2 жыл бұрын
You can use dropna =False in the pivot_table function :)
@AnjanBasumatary
@AnjanBasumatary 2 жыл бұрын
@@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
@elfridhasman4181
@elfridhasman4181 2 жыл бұрын
Wow, thank you very much 🙏🙏😍
@datagy
@datagy 2 жыл бұрын
Thanks for your comment, Elfrid!
@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: kzbin.info/www/bejne/o2HcZqinipJgj7M
@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 👍
@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 :)
@86Maryj
@86Maryj 2 жыл бұрын
Hi can you pls to pivot with multiple sheets
@XuanTran-ri1hn
@XuanTran-ri1hn 3 жыл бұрын
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 3 жыл бұрын
Hi Xuan, thanks for your comment! By default, a Pandas pivot table will calculate the average value :).
@XuanTran-ri1hn
@XuanTran-ri1hn 3 жыл бұрын
@@datagy Thanks :)
@ahmedhelal920
@ahmedhelal920 3 жыл бұрын
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 3 жыл бұрын
Hi Ahmed, thanks for your comment! Could you explain what you mean by porders?
@syedrizvi2687
@syedrizvi2687 3 жыл бұрын
Thank you so much!
@datagy
@datagy 3 жыл бұрын
Thanks so much for your comment!
@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! ;)
@tuandino6990
@tuandino6990 2 жыл бұрын
well explained!
@datagy
@datagy 2 жыл бұрын
Thank you!!
@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
@tobecontinued...5712
@tobecontinued...5712 4 жыл бұрын
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 4 жыл бұрын
Hi there! Is the "string" a number? i.e., "9" formatted as a string?
@tobecontinued...5712
@tobecontinued...5712 4 жыл бұрын
@@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 4 жыл бұрын
@@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?
@MrFishingo
@MrFishingo 3 жыл бұрын
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 3 жыл бұрын
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: kzbin.info/www/bejne/amK7fYeHfpaksKs 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).
@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.
@gouthamkarakavalasa4267
@gouthamkarakavalasa4267 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
@@datagy Hey, Thank u very much.. it worked:)
@datagy
@datagy 4 жыл бұрын
I’m so glad! Thanks for letting me know :)
@Diamond_Hanz
@Diamond_Hanz 3 жыл бұрын
NYC here...Data Science Major.
@datagy
@datagy 3 жыл бұрын
Welcome to the channel!
@boppanibhanuprasad4612
@boppanibhanuprasad4612 3 жыл бұрын
Plain and simple.
@datagy
@datagy 3 жыл бұрын
Thank you!
@MagnusAnand
@MagnusAnand 3 жыл бұрын
Cool video
@datagy
@datagy 3 жыл бұрын
Thanks Guz!
@milkway731
@milkway731 2 жыл бұрын
i just found if I set margin, the code will fail. Traceback (most recent call last)
@ShawVishal
@ShawVishal 4 жыл бұрын
Thanks
@datagy
@datagy 4 жыл бұрын
You’re welcome!
@kinanradaideh5479
@kinanradaideh5479 2 жыл бұрын
@6:21
@hhbbhvvbjhbbyjj
@hhbbhvvbjhbbyjj 3 жыл бұрын
u couldnt of made the video more clear
@datagy
@datagy 3 жыл бұрын
Thanks so much!!
@seekthehorizon6854
@seekthehorizon6854 3 жыл бұрын
😅😊
@Xiler6969
@Xiler6969 4 жыл бұрын
delete intro music
Pandas functions: merge vs. join vs. concat
16:15
Mısra Turp
Рет қаралды 27 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 280 М.
Pivot tables with Pandas
9:00
Python and Pandas with Reuven Lerner
Рет қаралды 44 М.
Python | Урок 15: Библиотека Pandas, часть 1
10:45
Мастерская Важных историй
Рет қаралды 42 М.
How to Reshape Dataframes | Pivot, Stack, Melt and More
12:49
Mısra Turp
Рет қаралды 27 М.
The Complete Guide to Python Pandas Groupby
44:17
Ryan & Matt Data Science
Рет қаралды 11 М.