Python Pandas Tutorial 10. Pivot table

This tutorial covers pivot and pivot table functionality in pandas. Pivot is used to transform or reshape dataframe into a different format. Pivot table is used to summarize and aggregate data inside dataframe.
Topics that are covered in this Python Pandas Video:
0:00 What is pivot?
1:02 Use pivot() function and its arguments
2:27 What is a pivot table?
2:41 Use pivot_table() in dataframe
4:33 Use "aggfunc" argument in pivot_table() function
7:48 Use Grouper() function to aggregate
Code used in this tutorial: github.com/codebasics/py/blob...
To download csv and code for all tutorials: go to github.com/codebasics/py, click on a green button to clone or download the entire repository and then go to relevant folder to get access to that specific file.
Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
Next Video:
Python Pandas Tutorial 11. Reshape dataframe using melt: • Python Pandas Tutorial...
Popular Playlist:
Complete python course: • Python 3 Programming T...
Data science course: • Data Science Full Cour...
Machine learning tutorials: • Machine Learning Tutor...
Pandas tutorials: • Pandas Tutorial (Data ...
Git github tutorials: • Git/Github Tutorial
Matplotlib course: • Matplotlib tutorial
Data structures course: • Data Structures And Al...
#️⃣ Social Media #️⃣
🔗 Discord: / discord
📸 Dhaval's Personal Instagram: / dhavalsays
📸 Instagram: / codebasicshub
🔊 Facebook: / codebasicshub
📝 Linkedin (Personal): / dhavalsays
📝 Linkedin (Codebasics): / codebasics
📱 Twitter: / codebasicshub
🔗 Patreon: www.patreon.com/codebasics?fa...

Пікірлер: 142

  • @codebasics
    @codebasics2 жыл бұрын

    Check out our premium machine learning course with 2 Industry projects: codebasics.io/courses/machine-learning-for-data-science-beginners-to-advanced

  • @anjankumar2517
    @anjankumar25172 жыл бұрын

    Sir, You are amazing! I am really happy today I am able to perform these tasks today in pandas. I am really happy for that. Kudos Sir, what ever you are doing is really service to this human society. This is really super altruistic nature.

  • @paintingmylifeawaify
    @paintingmylifeawaify7 жыл бұрын

    Great, great tutorial! You explain everything so wonderfully and clearly. Thank you!

  • @armagaan007

    @armagaan007

    5 жыл бұрын

    True

  • @isaacnewton7445
    @isaacnewton74456 жыл бұрын

    omg these vids are perfect for what I'm doing at my work. Exactly the kind of pandas info I was looking for. Thank you.

  • @timothypulliam2177

    @timothypulliam2177

    3 жыл бұрын

    Thank you for Gravity Sir Isaac Newton

  • @RockStar-pw5wd

    @RockStar-pw5wd

    3 жыл бұрын

    @@timothypulliam2177 😂😂😂

  • @shaikansari6882
    @shaikansari68826 жыл бұрын

    You are awesome man. You explain everything so clearly. Thank you so much

  • @nitinkumar29
    @nitinkumar293 жыл бұрын

    Best tutorials, clear and concise! Well done! Thank you so much!

  • @codebasics

    @codebasics

    3 жыл бұрын

    👍☺️

  • @judycalvo5127
    @judycalvo51274 жыл бұрын

    This is an awesome video--totally on spot for what I am learning in coding bootcamp

  • @codebasics

    @codebasics

    4 жыл бұрын

    Judy, I appreciate you leaving a comment of appreciation

  • @Osama-xs8cl
    @Osama-xs8cl7 жыл бұрын

    you r awesome man keep going your learning style is very interactive , come with new lessons

  • @hpourmamih

    @hpourmamih

    4 жыл бұрын

    He is AMAZING!!!!

  • @andyb1322
    @andyb1322 Жыл бұрын

    Great video -- very clear and concise, thanks!

  • @flamboyantperson5936
    @flamboyantperson59366 жыл бұрын

    Just loved it. Thank you.

  • @gaganutube2k8
    @gaganutube2k86 жыл бұрын

    Awesome tutorial in very easy way.

  • @robertbutscher6824
    @robertbutscher68244 жыл бұрын

    great explanation, thank you so much. stay safe

  • @rittervsp
    @rittervsp7 жыл бұрын

    thank you, it's easy and useful!

  • @anthonymclaughlin9222
    @anthonymclaughlin92223 жыл бұрын

    Thanks for the lesson! Really helpful!

  • @fefefefezzz
    @fefefefezzz Жыл бұрын

    It was a very good explanation. Thank you so much!

  • @multitaskprueba1
    @multitaskprueba12 жыл бұрын

    Excellent video! Thank you!

  • @BiancaAguglia
    @BiancaAguglia5 жыл бұрын

    Thank you. This helped a lot.

  • @codebasics

    @codebasics

    5 жыл бұрын

    Glad you found it useful Bianca. 😀

  • @eduardoteixeirajj
    @eduardoteixeirajj2 жыл бұрын

    Great video, thanks for sharing!

  • @AndrewDavidson-un2df
    @AndrewDavidson-un2df Жыл бұрын

    great video. your examples are very helpful

  • @amitmittal2453
    @amitmittal24534 жыл бұрын

    Sir, your tutorials are very useful :) They are easy to understand, thanks for your help Sir.

  • @codebasics

    @codebasics

    4 жыл бұрын

    👍👍👍

  • @hangout_in_america8536
    @hangout_in_america85366 жыл бұрын

    you are an angel:) thank you so much

  • @seslikitapalemi1106
    @seslikitapalemi11064 жыл бұрын

    Again very good lesson ,thank you

  • @prasantakarmakar8554
    @prasantakarmakar85544 жыл бұрын

    Very Sorted Educative video. within this short time I learned Pivot which I was not able to get From last week. Thanks a lot. Require Video on Pivot using If-Else in Python and CrossTab.

  • @hugolousa
    @hugolousa3 жыл бұрын

    Thanks for great quality class!

  • @codebasics

    @codebasics

    3 жыл бұрын

    You're very welcome!

  • @ishandaar
    @ishandaar4 жыл бұрын

    you are awesome man you helped me learn a new thing today

  • @chitrajain5059
    @chitrajain50596 жыл бұрын

    Your tutorials are great.It will be great if you can give some assignment at the end of every tutorial. And also some small projects where we can apply our learning. Thank you code basics.

  • @lysdexic4160
    @lysdexic41606 жыл бұрын

    this really helped me thank you very much :)

  • @codebasics

    @codebasics

    3 жыл бұрын

    I am happy this was helpful to you.

  • @MinhVu-bl4ss
    @MinhVu-bl4ss5 жыл бұрын

    It's very helpful thank you

  • @dr.k.gayathrideviprofessor5297
    @dr.k.gayathrideviprofessor52973 жыл бұрын

    Very Informative Session.

  • @CA_Sandeep_Modi
    @CA_Sandeep_Modi4 жыл бұрын

    you r awesome man keep going your learning style is very interactive , come with new lessons and advance pandas

  • @codebasics

    @codebasics

    4 жыл бұрын

    👍👍🙏😊

  • @tatavares1985
    @tatavares19855 жыл бұрын

    Great teacher! Tks

  • @Forever._.curious..
    @Forever._.curious.. Жыл бұрын

    Thankyou so much , for yr work I love it 💝

  • @upadisetty
    @upadisetty6 жыл бұрын

    awesome tut.

  • @SauravKumar-xg4zr
    @SauravKumar-xg4zr Жыл бұрын

    You gain a subscriber and a like :) Thanks for sharing this!

  • @mohammed333suliman
    @mohammed333suliman5 жыл бұрын

    Helpful, thank you

  • @usama57926
    @usama579262 жыл бұрын

    Good explanation....

  • @shrikant301991
    @shrikant3019915 жыл бұрын

    Great tutorials ..please upload more videos on Python along with it's applications

  • @codebasics

    @codebasics

    5 жыл бұрын

    sure. I just started a deep learning tutorial series with python today with first introduction tutorial. check it out on my channel.

  • @wanfaris9473
    @wanfaris94734 жыл бұрын

    Thank you sir! very helpful !

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad it helped

  • @SanskaarMishra
    @SanskaarMishra6 жыл бұрын

    you make things look easier........

  • @spicytuna08
    @spicytuna085 жыл бұрын

    awesome examples

  • @nikitasinha8181
    @nikitasinha8181 Жыл бұрын

    Thank you so much sir

  • @engineerbaaniya4846
    @engineerbaaniya48464 жыл бұрын

    love u sir ji you made our day

  • @Youtubeharyana
    @Youtubeharyana2 жыл бұрын

    Thank you sir.

  • @deepakjaju1549
    @deepakjaju15493 жыл бұрын

    You are No1.Super Duper

  • @learnopedia8808
    @learnopedia88082 жыл бұрын

    Great sir awesome

  • @reshaknarayan3944
    @reshaknarayan39443 жыл бұрын

    Very useful.

  • @nandanavarevinod4684
    @nandanavarevinod46843 жыл бұрын

    liked for your voiceover

  • @learnopedia8808
    @learnopedia88082 жыл бұрын

    God bless you and ur family

  • @David-lb1jx
    @David-lb1jx2 жыл бұрын

    Thank you sir

  • @ishanchourey2252
    @ishanchourey22525 жыл бұрын

    hey. If I want to perform a roll-up function on my dataframe, how should i go about it

  • @yes_i_am8378
    @yes_i_am83784 жыл бұрын

    Hey, Nice tutorial. Why don;t you use the command : shift+tab, for the documentation by clicking and pressing that command on that specific function?

  • @gameanand
    @gameanand Жыл бұрын

    Good Video

  • @akankshadhall5314
    @akankshadhall53144 жыл бұрын

    @codebasics, At time 2:49 in some rows it is showing "none" and in some it is "NAN". Kindly explain.

  • @abhishekranjan2617
    @abhishekranjan26173 жыл бұрын

    superb video, I love this video.....👌👌👌☺☺☺🙏🙏😍🥰

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad it was helpful!

  • @ROHIT-gv7xk
    @ROHIT-gv7xk4 жыл бұрын

    very nice

  • @sparc373
    @sparc3736 жыл бұрын

    Thanks for sharing this, can you tell me if there is any limit for number of lines or size of data to be processed.

  • @denisbaranoff
    @denisbaranoff4 жыл бұрын

    Helpful!

  • @codebasics

    @codebasics

    4 жыл бұрын

    Glad you liked it Dennis

  • @automatewithamit
    @automatewithamit4 ай бұрын

    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 ??

  • @N_145
    @N_1455 ай бұрын

    so good

  • @hemendrapratapsingh4219
    @hemendrapratapsingh42196 жыл бұрын

    How do I write in to existing csv/excel file by adding new column? i.e., If I have a data in one column (column A) and want to add one column with conditional formula which will show "Yes/No" against all the values of Column A in new Column B, how can we do it? e.g. I have one column A containing the Talk time (in secs) of people. In new column B, I want to put "Yes/No" based on the condition that if Talk time is less than 30 sec its "Yes" else "No". How can I do that?

  • @yashchhabra9185
    @yashchhabra91855 жыл бұрын

    Can you please tell me how to use the mode function in the aggfunc. I have a categorical data set , i tried this ''''''outlet_size_mode = train.pivot_table(values='Outlet_Size', columns='Outlet_Type',aggfunc=(lambda x:mode(x).mode[0]) )'''''' , below error is coming , error : '

  • @danielspector9280
    @danielspector92803 жыл бұрын

    thank you man

  • @codebasics

    @codebasics

    3 жыл бұрын

    You're welcome!

  • @jasonhu7399
    @jasonhu73995 жыл бұрын

    I have a question: why can't we use city as index for the first dataframe?

  • @aniketsahare6480
    @aniketsahare64805 жыл бұрын

    Need help . In excel , the fields which we fill in rows , columns , values . What is the code corresponding to that in pandas

  • @fengqingchu8399
    @fengqingchu83995 жыл бұрын

    hi, there is no aggfunc parameter in the current version of pandas?

  • @jayshreedonga2833
    @jayshreedonga2833 Жыл бұрын

    thanks sir

  • @Asparuh.Emilov
    @Asparuh.Emilov2 жыл бұрын

    That’s great! But what if I want to add a calculated field or calculated item to my pivot?

  • @sovravi
    @sovravi6 жыл бұрын

    How can I get output in as decimal rather it giving as floating numbers?

  • @patricechaula3430
    @patricechaula34302 жыл бұрын

    Thank you

  • @codebasics

    @codebasics

    2 жыл бұрын

    You're welcome

  • @hope1922
    @hope1922 Жыл бұрын

    How would it work if I have a df with two columns, id and value. I have two values per id and I want to pivot to end up with a new dataframe that is id, value1, value2?

  • @abhishekpanjiyar8266
    @abhishekpanjiyar82663 жыл бұрын

    i thank you sir

  • @PatelMahendra
    @PatelMahendra4 жыл бұрын

    @codebasics How to remove those unnecessary headers from pivot?

  • @spider279
    @spider279 Жыл бұрын

    Hello , very nice video , so how to replace NaN values to my new york column at 2:24 dealing with the SettingCopyWarning ?

  • @virgilioespina
    @virgilioespina4 жыл бұрын

    Can you do the reverse? columns to rows?

  • @rishabhsomething
    @rishabhsomething2 жыл бұрын

    great

  • @ojhaashirbad
    @ojhaashirbad4 жыл бұрын

    Hello bro, thanks all for your good work. Could you please tell me hot to export the entire pivot data into excel workbook including Indexing?

  • @umakantaparida6719
    @umakantaparida67194 жыл бұрын

    how to dowload the csv file from github i can't find out from the description please help anyone

  • @TheStainlessFish
    @TheStainlessFish4 жыл бұрын

    at 0:33 you say x axis dates and y is city!! shouldnt it be the opposite? please explain

  • @codebasics
    @codebasics5 жыл бұрын

    Step by step guide on how to learn data science for free: kzread.info/dash/bejne/iKKTz8-IpbTRg6Q.html Machine learning tutorials with exercises: kzread.info/dash/bejne/maGq2MOoktCdlbQ.html

  • @MrPrudhvisai
    @MrPrudhvisai4 жыл бұрын

    can calculate the average of humidity,temperature with respective to the city using groupby function. just like at 4:16

  • @akshaybanaye
    @akshaybanaye4 жыл бұрын

    pivot command gave an error: Index contains duplicate entries. Can not reshape."

  • @saurabhtiwari5525
    @saurabhtiwari55253 жыл бұрын

    Can we add multiple columns there ?

  • @bhavanidurga1251
    @bhavanidurga12512 жыл бұрын

    Thank you so much for sharing his video sir. Everyone understood easily sir. If you please share weather datasets through mail sir.

  • @AnjanBasumatary
    @AnjanBasumatary Жыл бұрын

    how to sort the cross tabs rows and column alphabetically?

  • @banduriambrish5092
    @banduriambrish50922 жыл бұрын

    Help me how to save pivot templet from python to csv

  • @TanvirAhmed-em7iv
    @TanvirAhmed-em7iv4 жыл бұрын

    index contains duplicate entries,cannot reshape........How to fix this problem?

  • @Sameer-o5f
    @Sameer-o5f15 сағат бұрын

    Hello Sir, I'm following the all videos in sequence, all are amazing. can you please help me to find out the practice files? In your blog I'm unable to find. this will be much helpfull

  • @rekhachander9985
    @rekhachander99852 жыл бұрын

    How can i download the CSV file?

  • @banduriambrish5092
    @banduriambrish50922 жыл бұрын

    Hi sir, How to save this pivot table in csv

  • @HawkingMerchant
    @HawkingMerchant3 жыл бұрын

    sirf you creates the best content available but i know python learning data science to get a job also giving time to java programming will it be able to get a job without a degree

  • @zes7215
    @zes72155 жыл бұрын

    not ax or not, do/can do any nmw

  • @rajatpati9099
    @rajatpati90995 жыл бұрын

    df5 = pd.read_csv("weather3.csv") df5 df['date'] = pd.to_datetime(df['date']) display(df[['date']],df5) df6 = df5.pivot_table(index=pd.Grouper(freq='M',key='date'),columns='city') I am getting TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'

  • @anuradhasrivastav9038
    @anuradhasrivastav90384 жыл бұрын

    How can I install pandas in python 3.8 Please guide

  • @navjotmannan7303
    @navjotmannan73035 жыл бұрын

    Can you pls suggest, what is the use case of pivot in pandas, when u can use excel or tableau? If the dataset is huge, anyways we won't be able to see the entire ouput in Jupyter Notebook?

  • @codebasics

    @codebasics

    5 жыл бұрын

    pandas can handle much more larger datasets then excel. Excel has limit on how many rows it can handle whereas pandas can handle millions of rows seamlessly. In terms of visualization also jupyters next gen version jupyter lab has come out which can handle rendering of many many rows very efficiently. I will add a tutorial on that in future.

  • @kumarn6984
    @kumarn6984Ай бұрын

    Hi Sir, im interested to learn python and related modules for data science or data analyst

  • @harishanmugam89
    @harishanmugam895 жыл бұрын

    I have a data in excel with 20 columns. I need to show the required data with 5 columns in Graphical or pie chart format. Can you help in getting that done??

  • @harishanmugam89

    @harishanmugam89

    5 жыл бұрын

    @@codebasics thank you will check and get back

  • @neil007sal
    @neil007sal3 жыл бұрын

    In this video, you said x axis is city at 0.41 but it actually looks like Y axis..and date as X axis.. correct me if I am wrong

  • @robertnelson9621
    @robertnelson96213 жыл бұрын

    pivot_table : pandas.core.base.DataError: No numeric types to aggregate

  • @mkarthikeyan9817
    @mkarthikeyan9817 Жыл бұрын

    How to download csv file

  • @atharvnikhare7113
    @atharvnikhare71134 жыл бұрын

    Not able to access the code file on github. Fix it and reply.