2

I'm having difficult once I'm trying to group the sum of ['ForecastSUM'] values by ['PNO'] column .

enter image description here

combined_sf2['ForecastWHSE'] = combined_sf2.groupby(by=['ForecastSUM', 'PNO']).sum().groupby(level= 
[0]).sum()

In this ['ForecastWHSE'], I would like to have the sum of ['ForecastSUM'] values grouped by PNO. For example, for the PNO = 8007205, I would like to have in this ['ForecastWHSE'] column the value of 13 (6+7).

I could create another dataframe which give me the rights values, but I was not able to include this right values on the full table on this 'ForecastWHSE'] specific column.

enter image description here

What should I do?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Yan
  • 107
  • 6
  • Do you need `transform` ? – jezrael Apr 22 '21 at 08:30
  • have you tried [pivot_table](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.pivot_table.html)? – Amri Rasyidi Apr 22 '21 at 08:31
  • No, I would like to do a pivot table, but I do not know how. So I would be able to reference the values from this second created with thte rights values. Could you help me in how to create this pivot table ? https://stackoverflow.com/users/9782019/amri-rasyidi – Yan Apr 22 '21 at 10:35
  • Any suggestions ? – Yan Apr 23 '21 at 13:46
  • https://stackoverflow.com/users/2901002/jezrael I mean create a new column with thus group by sum by PNO of the ForecastSUM. – Yan Apr 23 '21 at 13:47

0 Answers0