[Python] How to group a datetime column by year?

Discussão em 'Python' iniciado por Stack, Fevereiro 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dataframe with a column of type datetime64[ns]. I want to group rows by year. I unsuccessfully tried

    df1 = df.groupby(df.modification_datetime.year).sum()


    AttributeError: 'Series' object has no attribute 'year'
    ​

    Do you know how to solve that?

    Continue reading...

Compartilhe esta Página