Moving Average (Rolling Average) in Pandas and Python - Set Window Size, Change Center of Data

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии • 56

  • @claudio1417
    @claudio1417 2 года назад +4

    Hi Nick, I'm from Brazil and I'm following you, you can explain like no one else. Very cool your techniques and methods. Top. Congratulations.

    • @datagy
      @datagy  2 года назад +1

      Thanks Claudio! That made my day 😊

  • @mogith9648
    @mogith9648 2 года назад

    you're a lifesaver Nick. Keep going !

    • @datagy
      @datagy  2 года назад

      Thanks so much, Mogith!

  • @minhtu5059
    @minhtu5059 2 месяца назад

    Thank you so much for the tutorial!

  • @vijaykumarahamadabade9563
    @vijaykumarahamadabade9563 2 года назад +1

    your videos are very informative and easily explained. Just a request, please keep adding the dataframe generating codes in the description to follow along with you. Thank you :)

    • @datagy
      @datagy  2 года назад

      Thanks so much!

  • @reiskleiton
    @reiskleiton 4 года назад +2

    Hi Nick. Thank you very much for you explanation. It did help me to understand more about moving average. Keep up the good work.

    • @datagy
      @datagy  4 года назад

      Thanks so much Kleiton!

  • @pjakobsen
    @pjakobsen 2 года назад +1

    Excellent video, super clear

    • @datagy
      @datagy  2 года назад

      Thank you so much!

  • @karanpk1651
    @karanpk1651 2 года назад +1

    Very much useful. Thank you Bro... ❤️.

    • @datagy
      @datagy  2 года назад

      Thanks Karan!

  • @mays7n
    @mays7n Год назад +1

    thank you, very good video :)

  • @haxmal9065
    @haxmal9065 2 года назад +2

    dude thank you so much!

    • @datagy
      @datagy  2 года назад

      I’m glad it was helpful!

  • @nakshatragarg
    @nakshatragarg 3 года назад +1

    Thanks for an amazing explanation

    • @datagy
      @datagy  3 года назад

      Thanks so much!

  • @nadavnesher8641
    @nadavnesher8641 3 года назад +1

    Hi Nick. Great video, great explanation!! Thanks :)

    • @datagy
      @datagy  3 года назад +1

      Thanks Nadav! I'm glad it was helpful!

  • @RNSS0
    @RNSS0 3 года назад +1

    thank you, you helped me a lot

    • @datagy
      @datagy  3 года назад

      Thank you for your comment! I really appreciate it.

  • @Earths_Accountant
    @Earths_Accountant 4 года назад +1

    Thanks for the video!!

    • @datagy
      @datagy  4 года назад

      I’m glad you liked it!

  • @tuandino6990
    @tuandino6990 2 года назад +1

    clear explanation

  • @辛皓若
    @辛皓若 2 года назад

    hello,
    can we use timeperiods as a window?For example the average value of price per hour?

  • @uploadvoice
    @uploadvoice 4 года назад +1

    Very good video.

    • @datagy
      @datagy  4 года назад

      Thanks so much! I’m glad you liked it!

  • @LucaSpinello
    @LucaSpinello 4 года назад +1

    Thank you! If I wanted to do a rolling but exclude the most recent value from the calculation how would I do? Apply a shift to the data frame and then rolling? Thank you

    • @datagy
      @datagy  4 года назад

      Thanks for your comment, Luca!
      Exactly! You could slice the dataframe you're creating the rolling average first. If your most recent value is either the first or last value, I'd recommend using iloc. I've covered that here: ruclips.net/video/VIa1ETYnFuc/видео.html
      Let me know if you have any questions!

    • @LucaSpinello
      @LucaSpinello 4 года назад

      @@datagy Thank you for the quick response and the content, I find it really helpful!
      Back to the original question, I think if I use iloc I would need a for loop, while the rolling function would to it automatically, so if I want a rolling mean of the 5 previous elements for example (not considering the current value) I would do something like df.shift(1).rolling(5).mean() I think...
      is there a video coming up about shift?

    • @datagy
      @datagy  4 года назад

      @@LucaSpinello Hi Luca! Sorry, perhaps I misunderstood your original question. Are you looking to just drop the most recent value from your entire dataframe?

    • @LucaSpinello
      @LucaSpinello 4 года назад

      datagy, drop the most recent value only for the purpose of the mean calculation

    • @datagy
      @datagy  4 года назад +1

      @@LucaSpinello In that case, I'd drop the first (or last) rolling average calculation in your dataframe.
      In that case, I'd recommend iloc to set the value to missing. As your most recent value will sit at either the front or end, it will only be included in a single rolling calculation.
      It'll accomplish what you're hoping to do with pd.shift, but without as much work.

  • @shannatheragamuffin..743
    @shannatheragamuffin..743 3 года назад

    What would be the matlab equivalent of "movmean(x,3)" in python?

  • @AK-ss2de
    @AK-ss2de 3 года назад

    Good morning,
    Please, could you tell me how can I use the rolling regression with a granger causality test ? And to do this granger causality month by month?
    Thanks in advance :)

  • @user-wc7em8kf9d
    @user-wc7em8kf9d 4 года назад +1

    Thank you!

    • @datagy
      @datagy  4 года назад

      You’re welcome! I hope it was helpful!

  • @sekiro_19
    @sekiro_19 3 года назад +1

    thank you for your help

    • @datagy
      @datagy  3 года назад

      Thanks Sekiro!

  • @swarnachoppella388
    @swarnachoppella388 Год назад +1

    Thank you

    • @datagy
      @datagy  Год назад +1

      Thanks for your comment!

  • @kamaleshbarai2759
    @kamaleshbarai2759 3 года назад

    Nice explanation bro

    • @datagy
      @datagy  3 года назад +1

      Thanks Kamalesh!

  • @RenanBrito000
    @RenanBrito000 3 года назад +1

    how can i change the size of graph?

    • @datagy
      @datagy  3 года назад +1

      Hi Renan,
      You can use df.plot(figsize=(3,3))
      Hope this helps!

    • @RenanBrito000
      @RenanBrito000 3 года назад +1

      @@datagy thanks

  • @jazzbezz9394
    @jazzbezz9394 3 года назад +1

    How to determine the window size as 5?

    • @datagy
      @datagy  3 года назад

      Hi Jazz, You can use .rolling(5) or .rolling(window=5)
      Hope this helps!

  • @meghanachippada8051
    @meghanachippada8051 Год назад

    Hello! Can u please help in our code which is completely based on rolling average

    • @meghanachippada8051
      @meghanachippada8051 Год назад

      And thankyou Nick ! For this video

    • @datagy
      @datagy  Год назад

      Hey Meghana, thanks for your comment! What part of your code is causing you trouble?

  • @tomaspapantos1071
    @tomaspapantos1071 2 года назад +1

    👏👏

  • @vactum0
    @vactum0 2 года назад

    code link?