[英]Combine three Pandas Pivot Tables with different column numbers
我有三個大熊貓pivot_tables:
# First Pivot Table
# Total Sales of Product 1
Month
Branch 1 2 3
1 100.00 80.00 50.00
2 200.00 50.00 60.00
3 250.00 90.00 65.00
# Second Pivot Table
# Total Commission of Product 1
Month
Branch 1 2 3
1 10.00 8.00 5.00
2 20.00 5.00 6.00
3 25.00 9.00 6.50
# Third Pivot Table
# Sales Count (general including other products)
Month
Branch 2 3
1 5 5
2 1 6
3 3 6
當我嘗試結合三個樞軸數據幀時,出現錯誤: "cannot convert float NaN to integer"
。
我嘗試的命令:
dfResult = dfTotalSales.append(dfCommission).append(dfSalesCount)
除了上面的錯誤...
如何合並它們並返回凈銷售總額平均值的新列?
Formula: (Total Sales - Commission) / Sales account
提前致謝。
是您的數據就像分支1中的以下內容,第一個月的銷售額是100分支2中的第一個月的銷售額是80
如果是,則我認為分支1不存在銷售計數。即,根據我的理解,僅對分支2和3給出銷售計數。
因此在處理時,他嘗試填充空值,但除銷售計數外,數據均為整數。 因此它不能將float轉換為int。
因此,請全部設置為int或float,然后嘗試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.