是否有Python函数将1行转换为一列

时间:2019-06-22 05:05:01

标签: python-3.x pandas pivot pandas-groupby transpose

我做了很多事情,将使用情况数据(见下文)分成几列。

current df:
meterId    Consumption    usage    
1          1000           100
1          900            100
1          800            0
2          2000           500
2          1500           250
2          1250           150
2          1100           100
2          1000           0

我尝试了旋转,移调等操作。

What I want to achieve is the following:

meterId   Usage1 Usage2 Usage3 Usage4 Usage5
1         100    100    0      NAN    NAN
2         500    250    150    100    0

0 个答案:

没有答案