1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] group by week in pandas

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having this data frame:

    Name Date Quantity
    Apple 07/11/17 20
    orange 07/14/17 20
    Apple 07/14/17 70
    Orange 07/25/17 40
    Apple 07/20/17 30


    I want to aggregate this by Name and Date to get sum of quantities Details:

    Date: Group, the result should be at the beginning of the week (or just on Monday)

    Quantity: Sum, if two or more records have same Name and Date (if falls on same interval)

    The desired output is given below:

    Name Date Quantity
    Apple 07/10/17 90
    orange 07/10/17 20
    Apple 07/17/17 30
    orange 07/24/17 40

    Continue reading...

Compartilhe esta Página