How do I select multiple rows and columns from a pandas DataFrame?

Поділитися
Вставка
  • Опубліковано 6 чер 2016
  • Have you ever been confused about the "right" way to select rows and columns from a DataFrame? pandas gives you an incredible number of options for doing so, but in this video, I'll outline the current best practices for row and column selection using the loc, iloc, and ix methods.
    SUBSCRIBE to learn data science with Python:
    ua-cam.com/users/dataschool?su...
    JOIN the "Data School Insiders" community and receive exclusive rewards:
    / dataschool
    == RESOURCES ==
    GitHub repository for the series: github.com/justmarkham/pandas...
    "loc" documentation: pandas.pydata.org/pandas-docs/...
    "iloc" documentation: pandas.pydata.org/pandas-docs/...
    "ix" documentation: pandas.pydata.org/pandas-docs/...
    Summary of the pandas API for selection: github.com/pydata/pandas/issu...
    == LET'S CONNECT! ==
    Newsletter: www.dataschool.io/subscribe/
    Twitter: / justmarkham
    Facebook: / datascienceschool
    LinkedIn: / justmarkham

КОМЕНТАРІ • 811

  • @dataschool
    @dataschool  6 років тому +116

    As of pandas 0.20 (released May 2017), ix has officially been deprecated. Watch my new video, "5 new changes in pandas you need to know about", if you want to learn how to duplicate the functionality of ix using loc and iloc: ua-cam.com/video/te5JrSCW-LY/v-deo.html

    • @averyhr
      @averyhr 5 років тому

      Data School c

    • @lenac3587
      @lenac3587 4 роки тому +2

      Meh, lessons learned today. Should read comment first before sitting through the last confusing part on ix concept. Thanks for the tip that it's deprecated.

    • @DelandaBaudLacanian
      @DelandaBaudLacanian 4 роки тому +2

      thanks for the update, you're the best!

    • @Friends.shorts
      @Friends.shorts 4 роки тому

      thanks for update.

    • @anokhikumari6900
      @anokhikumari6900 4 роки тому +1

      you are genious

  • @elpintor2091
    @elpintor2091 5 років тому +140

    I love how he teaches, slow, thorough, easy to understand and with plenty of examples

    • @dataschool
      @dataschool  5 років тому +3

      Thanks so much for your kind comment!

    • @ankurgupta7102
      @ankurgupta7102 3 роки тому +1

      I watch it with 1.75 speed and still understandable

    • @mabelleth
      @mabelleth 3 роки тому +1

      Still applies today! I love it!

  • @igorballesteros6012
    @igorballesteros6012 5 років тому +139

    Your voice tone is perfect for learning. Great video!

  • @svin30535
    @svin30535 8 років тому +139

    Congratulations on your marriage! Thanks for making awesome data school videos, I learned and refreshed lots of my Python skills here.

    • @dataschool
      @dataschool  8 років тому +11

      Thanks for your kind words! :)

  • @michellelee7585
    @michellelee7585 4 роки тому +5

    Just discovered this channel and I'm already eager to explore more! Thanks for breaking things down so simply and with tons of useful examples. I especially love it when you highlight to us efficient vs non-efficient / bug-prone codes.

  • @prodigyswifeybaby
    @prodigyswifeybaby 7 років тому +13

    Your pace is excellent! I like how you show the different options and recommendations. Keep up the good work!

    • @dataschool
      @dataschool  7 років тому +1

      Thanks so much! I'm glad the pace and style of my videos is helpful to you!

  • @TomSkinner
    @TomSkinner 7 років тому +9

    Just wanted to pile on the accolades, thanks. Perfectly paced, clear, succinct. It was just what I needed.

    • @dataschool
      @dataschool  7 років тому

      Great to hear! Thanks so much for your kind comment.

  • @AlexanderArtamonov
    @AlexanderArtamonov 4 роки тому +2

    After a few days of reading pandas documentation and numerous 'tutorials' I finally get a general principle of how loc/iloc works, thank you!

  • @genet480
    @genet480 4 роки тому

    I really like all your video tutorials.You explain things in a very methodological sequence with high clarity and gentle approach which is vital for beginner data science learners. We are very fortunate to have a free access to such high-quality educational resource. You are one of my favorite you-tube instructors I have ever watched.
    Thank you one thousand times!!!

  • @RufusVidS
    @RufusVidS 5 років тому +31

    I dropped into this video from another video and am so happy it happened! You have a very clear voice in the video, you clearly know your stuff, you give plenty of good examples of good practice and practices to avoid, and are quite thorough. I enjoyed this one very much and plan to check the others out right away. Also, congrats on your marriage, I hope you are still happily together now that a couple years have passed!

    • @dataschool
      @dataschool  5 років тому +7

      Thanks so much for your incredibly kind words! I very much appreciate it! And yes, we are still married :)

  • @vman049
    @vman049 4 роки тому +1

    Have watched this videos to refresh myself on two separate occasions. Very clear and concise with excellent examples. Thank you!

    • @dataschool
      @dataschool  4 роки тому

      Thanks for your kind words!

  • @TheHoinoel
    @TheHoinoel 5 років тому +3

    you are a godsend! Thank you so much for these tutorials. I knew it couldn't be as complicated as other people always made it out to be!
    Much love

    • @dataschool
      @dataschool  5 років тому

      You're very welcome! Glad it was helpful to you :)

  • @rgseven6557
    @rgseven6557 2 роки тому

    Honestly, this is one of the best videos regarding panda data frames and column selection. Your explanation is to the point yet easy to comprehend. I sincerely thank you for taking the time to create this lesson. Its times like this where I consider myself so fortunate to have access to the internet. Subscribed!

  • @ChiefKamek
    @ChiefKamek 7 років тому +1

    I'd like to thank you for this series!
    You are a fantastic teacher: the videos are clear and of good quality, you go over everything in a relaxed way and explain everything thorougly.
    This series is helping me out a lot, great work!

    • @dataschool
      @dataschool  7 років тому +1

      Wow, thank you so much for your incredibly kind comment! It's really great to hear that the series is useful to you!

  • @TheFallibleFiend
    @TheFallibleFiend 5 років тому +2

    I've watched this video several times and followed through with the exercise. But I just used iloc at work for the first time. Very handy.

  • @chelseali4463
    @chelseali4463 4 роки тому +3

    Your explanations have been one the of best I have found so far on dataframes!

    • @dataschool
      @dataschool  4 роки тому

      Thanks very much for your kind words!

  • @mohamedel-gazzar5818
    @mohamedel-gazzar5818 3 роки тому +1

    legend absolute legend. I have been recently doing a course on data analysis and I keep coming back to this man's videos for help.

  • @michaelbachman5038
    @michaelbachman5038 7 років тому +1

    Your explanations are clear and comprehensive. Glad I found your channel. Look forward to viewing more of your videos. Thank you!

    • @dataschool
      @dataschool  7 років тому

      Thanks so much for your kind comment!

  • @uh6537
    @uh6537 3 роки тому

    I have stuggled a bit with loc and iloc but after 12 min here everything just became clear. Thanks for an awesome explanation of this topic.

  • @RaynerGS
    @RaynerGS 6 років тому +2

    Good job, thanks! Keep on speaking high and clean as like in this video, this way facilitates so much for who is no English spoken native.

    • @dataschool
      @dataschool  6 років тому +1

      I'm glad to hear that my teaching style works for you! Really appreciate your comment :)

  • @pressiyamu2187
    @pressiyamu2187 4 роки тому +2

    Dude this was like the one function that I couldn't comprehend. Thanks a ton!

  • @altunbikubra
    @altunbikubra 5 років тому

    Thank you so much for the differentiation. I have taken an e-learning which now I realize that they did not even mention fatal functions of these usages. Now I can run my code, thank you !!!

  • @PawanBathe
    @PawanBathe 4 роки тому +1

    Awesome buddy, I watched it 2x still was able to follow along , because I had some familiarity around the concept , but others are also praising you for slow explanation, that's unique, suits for both, thanks for clarity of audio. very concise and clear.

    • @dataschool
      @dataschool  4 роки тому

      Thanks for your kind words!

  • @MK-xm2nh
    @MK-xm2nh Рік тому +3

    Your tutorials are very useful, and contain a good number of use cases for the duration. Thank you!

  • @sanaullahkhanhassanzai8432
    @sanaullahkhanhassanzai8432 5 років тому +1

    You are one of the best on you tube and the best on Pandas without a doubt, Keep up the good work. Thank you so much for the videos

  • @PatrickBateman12420
    @PatrickBateman12420 6 років тому +1

    Wow, best explanation on iloc/loc I have ever seen !!! Thank you for sharing!!!

    • @dataschool
      @dataschool  6 років тому

      Thanks so much! I worked very hard on that video :)

  • @anastasiyan44
    @anastasiyan44 4 роки тому

    the best explanation I've come across, and it actually applies to all your videos. Thank you!

  • @irakliberidze156
    @irakliberidze156 3 роки тому +1

    Big thanks for your job!!! Do not stop. too many people need video tutorials like this. waiting your new videos.

  • @ahe970
    @ahe970 Рік тому +1

    Really great - though 4 years old video. Just learning Python and found u to be a great teacher. I will look for ur other videos Thanks

  • @TR3NDSETR
    @TR3NDSETR 4 роки тому

    My brain is fried. I just watched 19 videos in 2 days and did every example also. But after watching I feel so much more confident. Im taking a class in a tech school currently, but your teaching is so much clearer. I learn more here, than in my class. My class is sooo fast, and long 5hr sessions at a time, its soo difficult to comprehend everything. Your videos are amazing. Thanks.

    • @dataschool
      @dataschool  4 роки тому

      That is so awesome to hear... thank you so much!

  • @harrykaranikas7741
    @harrykaranikas7741 3 роки тому

    Still...
    The best videos for Pandas on UA-cam!
    Thank you!

  • @mandyma7243
    @mandyma7243 3 роки тому +1

    Thank you for being patient and really informative!

  • @ziaw123
    @ziaw123 3 роки тому

    Hi, this is the best explanation ever!!! Super clear and you teach it slowly and show us different ways of doing and also why we should/should not use certain methods.
    This is so helpful!!!
    Thank you so much!!!

  • @michaelakatwijuka3465
    @michaelakatwijuka3465 6 років тому

    I really have not found explanations as clear as this.Thank you Steven

    • @dataschool
      @dataschool  6 років тому

      Glad it was helpful to you!

  • @rajsx5
    @rajsx5 7 років тому +1

    Congratulations on your Marriage!!
    And thanks for creating so neat and informative videos, learned a lot, I really appreciate it.
    Thanks again!

    • @dataschool
      @dataschool  7 років тому

      Thanks so much for your kind words and your well wishes! :)

  • @nicholasroman8071
    @nicholasroman8071 3 роки тому +1

    Very nice systematic break down of how to drill into a dataFrame. It was worth my time to watch this video.

  • @joro8604
    @joro8604 3 роки тому +1

    Well done! Thanks for going over the "proper" way first, and then the shortcuts. Most docs and tutorials, go straight to the shortcuts which is frusterating for a newb or even intermediate.

  • @zackhicks2433
    @zackhicks2433 5 років тому

    Thanks for these videos - hands down the best videos online for learning how to data science.

    • @dataschool
      @dataschool  5 років тому

      Thank you so much for your very kind comment!

  • @suhanasharma2965
    @suhanasharma2965 4 роки тому

    your way of teaching is too good sir.thanks a lot

  • @dean8147
    @dean8147 4 роки тому +3

    Amazing video. Been a few years since i last had any work related to Python.

  • @aabedkashwa9125
    @aabedkashwa9125 6 років тому +2

    i swear to god, i love you and your talent in teaching .. you are an awesome teacher, sir
    this helped me alot, God Bless you.

    • @dataschool
      @dataschool  6 років тому

      Thank you so much! I'm so glad to be of help to you!

  • @rinmulder2008
    @rinmulder2008 3 роки тому

    The pace and tone is excellent. Thanks for making the simple things clear. I am a subscriber now

  • @JonathanDewetfunlifegod
    @JonathanDewetfunlifegod 6 років тому

    Great video. Your voice is very clear even when sped up and you explained the concepts very well. Thank you.

  • @jaydock1
    @jaydock1 2 роки тому +1

    this is the most clear version of this I've found! great stuff

  • @Diachron
    @Diachron 7 років тому

    Another winner of a video that cuts through the fog usually surrounding these methods. And congrats on the wedding.

  • @noo-sho8500
    @noo-sho8500 4 роки тому +1

    I think you're the best data science python tutor I had seen :D

  • @harrwoodhouse2435
    @harrwoodhouse2435 3 роки тому +2

    Thank you so much, I've been stuck on this issue for ages!

  • @diegomedinaflores3362
    @diegomedinaflores3362 4 роки тому

    I found your video because I got this Warning: SettingWithCopyWarning:
    And you helped me to fix that issue.
    Thanks you a lot from Perú.

  • @ihaveoutside4959
    @ihaveoutside4959 2 роки тому +1

    I know these vids are older, but thank you. You are an excellent teacher!

  • @220piyush
    @220piyush 3 роки тому

    Thank You for this!!! I had so confusions regarding this topic and looking for a such a clear and informative video.

  • @carlosastro21
    @carlosastro21 6 років тому

    My friend, you have no idea how useful was this lecture for me. Pandas was turning in such a nightmare. And I don't even use it, ascii files have been good enough for me until today. But as a python user I wanted to check what I was missing with Pandas, and after many tries I was not understanding its logic. Even worse, I tried with MultiIndexed files from the beginning, so I was hopelessly crashing against a wall. But your input was really illuminating. So many subtleties.Thanks a lot! And best wishes in your marriage and future plans. Cheers

    • @dataschool
      @dataschool  6 років тому

      That is so great to hear, thank you for sharing! I really appreciate it!

  • @Seanog1231
    @Seanog1231 7 років тому +1

    Thank you for the great instruction and welcome to the club!

  • @DelandaBaudLacanian
    @DelandaBaudLacanian 4 роки тому

    12:21 nice summary of loc() vs iloc(), lots of good information

  • @balford2112
    @balford2112 Рік тому +1

    Thank you so much for this video. Very easy to understand and comprehensive.

  • @Gloryisfood
    @Gloryisfood 3 роки тому +1

    Most useful tutorial I've seen so far. Brilliant!

  • @fluffmiller1084
    @fluffmiller1084 7 років тому +1

    Wow
    This is a beacon of light in a sea of generally pretty badly presented and confusing UA-cam vids/moocs/other resources (including paid ones!) about pandas.
    Thank you for taking the time to make this video. It addresses such an obvious point of confusion that, having seen it, I'm left wondering why almost no one else takes the time to clarify the differences between the three indexing methods.
    I particularly liked the fact that you didn't just present syntax, you gave the reasons why the syntax is the way it is. So much pandas (and some python) teaching simply presents syntax with the expectation that you'll remember it. When you understand why it is how it is, you don't need to commit half as much stuff to memory.
    Thanks

    • @dataschool
      @dataschool  7 років тому

      Thanks so much for your thoughtful compliment! For every video, I spend a lot of time thinking about what to present, how to present it, and what details to include and exclude. I'm so glad to hear that my teaching methodology works well for you!

  • @harijayaram
    @harijayaram 7 років тому

    you are a very good teacher ...thanks again...i'm always using loc from now on

    • @dataschool
      @dataschool  7 років тому

      Thanks for your kind words!

  • @rutviktidke07
    @rutviktidke07 3 роки тому +1

    Best channel for learning python... kudos to you 👏

  • @sumanhalder1539
    @sumanhalder1539 4 роки тому

    Excellent explanation: was perplexed by various indexing protocols previously. Great pace and explanation was really helpful.

  • @poonamsachdeva9172
    @poonamsachdeva9172 6 років тому

    Excellent video, very clear and practical description. I will watch your other videos on Python and Pandas as well. Thanks a lot.

    • @dataschool
      @dataschool  6 років тому

      Thanks for your kind words!

  • @AZ993k
    @AZ993k Рік тому

    Thank you! That's just what I've looked for, in brief

  • @goldensleeves
    @goldensleeves 3 роки тому

    This is GREAT. I'm in a software school right now and they did a MUCH WORSE job of explaining this. THANK YOU for this video. Thumbs up

  • @scottlucas3710
    @scottlucas3710 7 років тому +2

    SUPER CLEAR TUTORIALS. NICE JOB

  • @Mufc_maddy
    @Mufc_maddy 4 роки тому +1

    Very nice video, Clearly understand the loc, iloc concept.

  • @yasermahfouz6263
    @yasermahfouz6263 3 роки тому +1

    your lectures and your examples are very nice , thank you

  • @georgesmith3022
    @georgesmith3022 5 років тому

    great explanation, perfect voice tone and pace

  • @gergstrMoz
    @gergstrMoz 4 роки тому +1

    I'm only 4 minutes in and already, thank you thank you thank you!!!

  • @UncleLoren
    @UncleLoren 4 роки тому

    It's interesting that .loc, though not the conventional choice of expression when specifying rows by NUMERIC POSITION, does in fact work provided the row index names are numeric. In contrast, .loc is not an option when specifying columns by numeric position (well, not unless the columns had numeric names). This video series is great for both "beginners" and for those who want a refresher b/c they've been spending more time using data frames in R and want to keep their muscle memory flexible to both worlds. Thanks a million, Kevin!

  • @sibinh
    @sibinh 7 років тому +14

    You did a great job!
    Happy wedding!

  • @kapilag
    @kapilag 6 років тому

    Very clear and sound explanation. Thanks a lot Kevin!!

  • @ragavsathis
    @ragavsathis 6 років тому

    Thanks for detailed explanation, able to solve my problem and understand in detail about loc

  • @archana0404
    @archana0404 6 років тому

    Each video is nicely explained. Well done. Thankyou somuch for sharing these video.

  • @niceday2015
    @niceday2015 2 роки тому +1

    Thank you very much, I like your video very much, very clear! And the speed is perfect for learning!

  • @Taran72
    @Taran72 4 роки тому +1

    Great Video! Ideal for a beginner like me. you explain everything in detail and straight to the point.

  • @nickiexu9919
    @nickiexu9919 7 років тому

    So far the best tutorials for pandas that I've ever seen.
    I like you explained in great details in both codes and logic.
    Your speed is slow and clear, leaves great room for audience to think.
    The examples are well designed, serve well for the purpose.
    I will try to go thru all your videos!
    Congrats to you for your marriage!
    Do you have videos on Groupby?

    • @dataschool
      @dataschool  7 років тому

      Wow, thanks so much for your kind words! I really appreciate it!
      I do have a video about groupby: ua-cam.com/video/qy0fDqoMJx8/v-deo.html
      Hope that helps!

  • @urso15
    @urso15 4 роки тому +6

    Aside from the good video, your way of speaking makes the content easier to understand to non-English native speakers.

  • @saurabh75prakash
    @saurabh75prakash 5 років тому +4

    Liked before watching, coz I know whats coming!

  • @amarn22
    @amarn22 7 років тому

    Brilliant. You are a star. You must do more videos in python machine learning and NLP

  • @haisonduong4726
    @haisonduong4726 7 років тому

    Your videos help me save a lot of money! Thanks!

  • @ManikandanRaju
    @ManikandanRaju Рік тому

    If had a million dollar with me, I would straight up come to you and give you the cash and learn from you. OMG!! You are a gem sir.
    I am new to Python. I'm finding all your videos extremely useful. Beautifully explained, clear and concise. Slow and steady.
    What else does one need!
    Hats off!!!! Thank you so much.

    • @dataschool
      @dataschool  Рік тому +1

      WOW! Thank you so much! I really appreciate your kind words! 🙏

  • @prashantjoshi8847
    @prashantjoshi8847 7 років тому +2

    He is a great teacher,I wish he could be my professor,Great work Sir :-)

    • @dataschool
      @dataschool  7 років тому

      Thanks so much, I appreciate your comment! :)

  • @harikrishna-harrypth
    @harikrishna-harrypth 3 роки тому +1

    Your videos are very helpful! Thanks much!

  • @FFGaming32207
    @FFGaming32207 11 місяців тому +3

    Incredible explanation. Thanks a lot ❤❤

  • @user-zy8sf7tv2f
    @user-zy8sf7tv2f 3 роки тому +1

    Man you are incredible, thanks for your teaching.

  • @hhbbhvvbjhbbyjj
    @hhbbhvvbjhbbyjj 2 роки тому +1

    wow this video is so clear and super helpful!

  • @selimtanrverdi9639
    @selimtanrverdi9639 3 роки тому +1

    Very very useful series. Thank you so much.

  • @chitranngoc9821
    @chitranngoc9821 2 роки тому +1

    Excellent video. I learned a lot from this video. Thank you very much.

  • @angelanganga2945
    @angelanganga2945 2 роки тому +1

    Awesome video, very easy to understand. Thanks

  • @louisthiebaud9999
    @louisthiebaud9999 3 роки тому

    Remarquable et très pédagogique! Félicitations pour la qualité de votre prononciation. Thanks a lot!

  • @davidpaez_co
    @davidpaez_co 5 років тому

    You explain things wonderfully, thank you!

  • @dtsleite
    @dtsleite 2 роки тому +1

    Great explanation and examples! helps a lot! Thanks!

  • @markslima1557
    @markslima1557 Рік тому

    this video is a little older but great content great instruction - you are making this really clear for me

  • @dhanushanthpushparajah1878
    @dhanushanthpushparajah1878 7 років тому

    This videos are awesome. Simple and clear. Thanks a lot brother.

    • @dataschool
      @dataschool  7 років тому

      Thanks so much for your kind words!

  • @pphong
    @pphong 6 років тому +1

    Thanks! Best explanation on loc/iloc!

  • @winstonloke2860
    @winstonloke2860 5 років тому

    Clear and concise, well done!

  • @jmachado9875
    @jmachado9875 5 років тому +2

    I'm amazed at the clarity with which you explain those concepts and teach how to use them in a professional manner. I'm really glad I found your youtube channel!
    Can I also ask you what technique would you recommend to copy ranges and paste them into another excel file (appending, not overwritting)?
    Thank you very much for your shared knowledge.

    • @dataschool
      @dataschool  5 років тому +1

      Thanks very much for your kind words! Really appreciate it.
      As for your question, I don't know off-hand, but you could search through the API documentation to see if anything is available: pandas.pydata.org/pandas-docs/stable/api.html

    • @jmachado9875
      @jmachado9875 5 років тому

      Once again, extremely helpful! I'll look it up.
      Thank you for your kindness.

  • @drhf1214
    @drhf1214 5 років тому +1

    thank you so much. This video was very helpful. Thanks for the many examples.

  • @CKPSchoolOfPhysics
    @CKPSchoolOfPhysics 2 роки тому +1

    Thanks a lot man !! You did a great favour to me !! ❤️

  • @Neerajkumar-ii5op
    @Neerajkumar-ii5op 5 років тому +2

    Very well explained. Thank you very much.

  • @ashishganga420
    @ashishganga420 6 років тому

    Awesome Tutorial for absolute beginners..Really appreciate that sir..Thank You...