Basic grouping in pandas

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • Grouping is a key skill when working with pandas. In this video, I show you what grouping means, how it works, and how you can apply it to your own data frames.
    (Oh, and wondering why I loaded the datetime column, but didn't use it? I decided to put it in the next video. Watch for it soon!)
    The notebooks I use on my TH-cam channel are all available at github.com/reu....
    And for free, weekly Python articles, subscribe to my newsletter at BetterDevelope....

ความคิดเห็น • 17

  • @veganath
    @veganath 2 ปีที่แล้ว +2

    Probably the most under viewed tutorial, thank you sir. Thumbs up & subbed

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      Happy to know you enjoyed it!

  • @loli2141
    @loli2141 ปีที่แล้ว +1

    THANKS

  • @akrm3240
    @akrm3240 2 ปีที่แล้ว +1

    Thank you so much!

  • @dkibe6006
    @dkibe6006 ปีที่แล้ว +1

    wooow! amazing

  • @omprakashreddy4230
    @omprakashreddy4230 2 ปีที่แล้ว +1

    Simply WOW !!

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      Delighted you enjoyed it!

  • @_truthful_q_
    @_truthful_q_ ปีที่แล้ว +1

    One of those jems (Reuven that is) - you look at the clock and wonder where the time went, if you know you know 😉

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Thanks so much, delighted to know you're enjoying!

  • @uptronstudio
    @uptronstudio ปีที่แล้ว +1

    Thanks for this Reuven. Is it possible to use groupby and at the same time display all the affected rows?

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Remember that groupby is for aggregation, which generally speaking means that a function takes a lot of values as an input, and returns one value as an output. For example, mean is an aggregation method; run it on a series, and you get back a single (numeric) value.
      The point of groupby is to call an aggregation function repeatedly on a data frame, once for each categorical value in a particular column. You'll thus get back one value from the aggregation function for each of the categorical values.
      All rows are affected by the groupby; the grouping doesn't do any filtering, but rather calls an aggregation function on each row. I'm thus not quite sure what it would mean to display affected rows.
      If you can give me a more specific, concrete example, I'll gladly try to help!

  • @saiful305
    @saiful305 ปีที่แล้ว +1

    How I should sort "How many trips are occurred per month?" and "Which hour of the day had the most frequent trips?"

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      For the first, you would group on the month, and use the count method. For the second, you could group on the hour, and use count - then sort by the values.
      Does that make sense?

    • @saiful305
      @saiful305 ปีที่แล้ว +1

      @@ReuvenLerner I am trying to do that. Thanks. 😁