,我有以下數據:在大熊貓擴大行數據幀
product Sales_band Hour_id sales
prod_1 HIGH 1 200
prod_1 HIGH 3 100
prod_1 HIGH 4 300
prod_1 VERY HIGH 2 100
prod_1 VERY HIGH 5 253
prod_1 VERY HIGH 6 234
要添加一個基於hour_id值的行。 hour_id變量的值可以從1到10。因此,上述相同的數據將在缺少小時id的位置展開。虛擬輸出:(銷售= 0失蹤小時ID)
product Sales_band Hour_id sales
prod_1 HIGH 1 200
prod_1 HIGH 2 0
prod_1 HIGH 3 100
prod_1 HIGH 4 300
prod_1 HIGH 5 0
prod_1 HIGH 6 0
prod_1 HIGH 7 0
prod_1 HIGH 8 0
prod_1 HIGH 9 0
prod_1 HIGH 10 0
prod_1 VERY HIGH 1 0
prod_1 VERY HIGH 2 100
prod_1 VERY HIGH 3 0
prod_1 VERY HIGH 4 0
prod_1 VERY HIGH 5 253
prod_1 VERY HIGH 6 234
prod_1 VERY HIGH 7 0
prod_1 VERY HIGH 8 0
prod_1 VERY HIGH 9 0
prod_1 VERY HIGH 10 0
我怎麼能做到這一點使用python數據幀時。
您應該結束了,每個產品和銷售帶10行? –
是的,這應該是理想的最終輸出 – Mukul