python sumif在数据范围内具有一个条件

发布于 2025-01-24 18:59:27 字数 1546 浏览 1 评论 0原文

I'm working with two dataframes

  • MRP:
MaterialDescriptionSeptiembre
1208181ADSV,NA,MX,ADH HOTMET 814433PM630.2888856
1206500SHWP,NA,MX,WRAP M-WRAP 18'459.4193011
3049172INSR,LUFTL,BR,LUFTAL0
3049173CLOS,LUFTL ,BR,Berry0
3060614Botl,Luftl,BR,LDPE/HDPE 15 ml0
  • SMCALC:
材料说明品牌可用数量可用。 -6mth。9月
0324583,蓝色,20mlMCN921888980554.96
0327757CLOS,MUCNX,US,CR24MM95094006219256.1724071020442
氨基MCN38020.3542PIC1120252
TARTARICNA64203.289乙酰6784.4993MEAS
,MUCNX, USAICIC粉粉43217.089370.0843

我正在excel中使用此公式:=+sumif(mrp!$ a:$ a,$ a2,mrp!c:c)其中:

  • range 是mrp !

​f in smcalc

I'm working with two dataframes

  • MRP:
MaterialDescriptionSeptiembre
1208181ADSV,NA,MX,ADH HOTMET 814433PM630.2888856
1206500SHWP,NA,MX,WRAP M-WRAP 18'459.4193011
3049172INSR,LUFTL,BR,LUFTAL0
3049173CLOS,LUFTL,BR,BERRY0
3060614BOTL,LUFTL,BR,LDPE/HDPE 15 ML0
  • SMCalc:
MaterialDescriptionBrandAvailable QtyAvail. - 6mth.sep
0324583MEAS,MUCNX,US,BLUE,20MLMCN921888980554.96
0327757CLOS,MUCNX,US,CR24MMMCN95094006219256.172975724.64
1019906ACETAMINOPHEN DC 90 COARSE LTEM43900-4443.5314387372.2407
1020442ACETAMINOPHEN POWDERNA64203.28938020.35426784.4993
1120252TARTARIC ACIDPIC43217.089370.0843

And I'm using this formula in excel: =+SUMIF(MRP!$A:$A,$A2,MRP!C:C) where:

  • Range is MRP!A:A (Material)
  • Criteria is SMCalc $A2 (Material)
  • Sum range is MRP!C:C (Septiembre)

The output I'm looking for is the column F in SMCalc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2025-01-31 18:59:27

“材料”匹配MRP中的MRP C列中的“ septiembre”总和。

如果我没有错,那Excel公式会在MRP中的 做:

mrp.groupby('Material')['Septiembre'].sum().reset_index()

在MRC中找到“ septiembre”的总和。然后将其与其他数据帧合并:

smcalc.merge(mrp.groupby('Material')['Septiembre'].sum().reset_index(),how='left')

然后将这些值带回Smcalc,我们希望它们成为

If I'm not wrong, that excel formula calculates the sum of 'Septiembre' in column C of MRP when 'Material' in SMCalc matches 'Material' in MRP...

Assuming you have both excel sheets as pandas dataframes, I would then do:

mrp.groupby('Material')['Septiembre'].sum().reset_index()

To find the sum of 'Septiembre' per material in mrc. Then merge that with the other dataframe:

smcalc.merge(mrp.groupby('Material')['Septiembre'].sum().reset_index(),how='left')

To then bring back those values to smcalc where we want them to be

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文