python数据处理——记录一个不知道怎么称呼但是很叼的操作

 首先在处理之前呢,这个df_all是长这样的:

经过如下的代码变换:

region_up = pd.pivot_table(df_all.groupby(["time", "region"])["up"].sum().reset_index(), values="up", index="time", columns="region")

之后的dataframe是长这样的:

猜你喜欢

转载自blog.csdn.net/m0_37876745/article/details/114538665
今日推荐