How to group pandas DataFrame entries by date in a non-unique column

How to group pandas DataFrame entries by date in a non-unique column

Asked on December 24, 2018 in Pandas.
Add Comment


  • 2 Answer(s)

    To get better performance for the pandas version 0.16.2 and up use the below code:

    data.groupby(data.date.dt.year)
    

    The parameters weekofyear, dayofweek of the dt function can be used.

    Answered on December 24, 2018.
    Add Comment

    For the best solution use the below code:

    data.groupby(lambda x: data['date'][x].year)
    
    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.