16.Pandas将时间戳格式改为YYYY-mm-DD hh:MM:ss (to_datetime()方法)和从日期中快速取成月份

时间戳格式改为YYYY-mm-DD hh:MM:ss

df['pdate']=pd.to_datetime(df['Timestamp'],unit='s')

从日期中快速取出月份

df_group=df.groupby([df["pdate"].dt.month,"Rating"])["UserID"].agg(np.sum)

更具体参考:https://blog.csdn.net/qq_39290225/article/details/98313743

posted @ 2020-07-23 20:52  hisweetyGirl  阅读(948)  评论(0编辑  收藏  举报