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




[ad_1]

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:
https://www.youtube.com/dataschool?sub_confirmation=1

JOIN the “Data School Insiders” community and receive exclusive rewards:
https://www.patreon.com/dataschool

== RESOURCES ==
GitHub repository for the series: https://github.com/justmarkham/pandas-videos
“loc” documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html
“iloc” documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iloc.html
“ix” documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html
Summary of the pandas API for selection: https://github.com/pydata/pandas/issues/9595

== LET’S CONNECT! ==
Newsletter: https://www.dataschool.io/subscribe/
Twitter: https://twitter.com/justmarkham
Facebook: https://www.facebook.com/DataScienceSchool/
LinkedIn: https://www.linkedin.com/in/justmarkham/

Source


[ad_2]

Comment List

  • Data School
    November 22, 2020

    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: https://www.youtube.com/watch?v=te5JrSCW-LY&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=33

  • Data School
    November 22, 2020

    Awesome video!

  • Data School
    November 22, 2020

    Are there other ways to import the url than converting it immediately to a DataFrame? Thanks for great videos!

  • Data School
    November 22, 2020

    omg u reminds me of Sheldon from big bang theory

  • Data School
    November 22, 2020

    perfect.

  • Data School
    November 22, 2020

    It is late but congratulations 🙂

  • Data School
    November 22, 2020

    Thanks a lot bruh..! Its really helpful
    if I use .ix i am getting this error " AttributeError: 'DataFrame' object has no attribute 'ix'
    " . Any other way to use similar command so that i can select rows and columns with both labels and integers

  • Data School
    November 22, 2020

    Thanks for the amazing video. Quick question: loc selects things by labels. However, in ufo.loc[ufo.City == "Oakland", :] the boolean condition isnt a label, right?

  • Data School
    November 22, 2020

    this is great!! thanks

  • Data School
    November 22, 2020

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

  • Data School
    November 22, 2020

    The ix is not working for the current version Pandas?

  • Data School
    November 22, 2020

    Debo decirte que te ameeeee. Mil gracias

  • Data School
    November 22, 2020

    thanks a lot, god bless you

  • Data School
    November 22, 2020

    ok can you go back in time and teach all my high school classes when you get a chance? thanks

  • Data School
    November 22, 2020

    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.

  • Data School
    November 22, 2020

    .ix is deprecated already!!!!!!!!!!!!! BAM

  • Data School
    November 22, 2020

    Hello thank you very much for this video…. I have one problem if we want to select all the rows but excluding few rows , how can we do that

  • Data School
    November 22, 2020

    Great videos, Can you please make video on pivot, pivot_table, melt ,all these kinds of transformations ? They are super confusing .

  • Data School
    November 22, 2020

    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

  • Data School
    November 22, 2020

    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.

  • Data School
    November 22, 2020

    Superb

  • Data School
    November 22, 2020

    Kind of late..but congratulations on getting married!!

  • Data School
    November 22, 2020

    Simply brilliant simple explanations, superb communicator.

  • Data School
    November 22, 2020

    Thanks for making such kind of videos, no doubt you are the best in the business, I watched a lot others videos but the way you explain things nobody can match that, please dont stop making videos even if you become millionaire;) thanks YouTube for recommending your channel to me.

  • Data School
    November 22, 2020

    Good video, mkay.. .So. Keep up the good work.

  • Data School
    November 22, 2020

    Happy married life bro….

  • Data School
    November 22, 2020

    sorry. I have a question about when i use 'ix'. The error show :'DataFrame' object has no attribute 'ix'

  • Data School
    November 22, 2020

    This is Gold

Write a comment