繁体   English   中英

合并三个具有不同列号的Pandas数据透视表

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM