grouping by day of the week pandas

前端 未结 3 1220
后悔当初
后悔当初 2021-01-28 17:10
  I have a dataframe,df 

        Index       eventName Count   pct
     2017-08-09       ABC     24     95.00%
     2017-08-09       CDE    140     98.50%
     2017-08-         


        
3条回答
  •  -上瘾入骨i
    2021-01-28 17:24

    You can use:

    df.rename(columns={'Index': 'New_name'}, inplace=True)
    
    df['New_name'] = pd.to_datetime(df['New_name'])
    
    df['Day_df'] = df['New_name'].dt.weekday_name
    
    df.groupby(['Day_df']).count()
    

提交回复
热议问题