Modify Value of Pandas dataframe Groups
问题 We have the following dataframe (df) that has 3 columns. The goal is to make sure that the summation of "Load" for each group based on IDs is equal to 1. pd.DataFrame({'ID':['AEC','AEC','CIZ','CIZ','CIZ'],'Load':[0.2093275,0.5384086,0.1465657,0.7465657,0.1465657]}) Num ID Load 1 AEC 0.2093275 2 AEC 0.5384086 3 CIZ 0.1465657 4 CIZ 0.7465657 5 CIZ 0.1465657 If a group's total load is less or more than 1, we want to add or subtract from only one member of the group to make the summation equal 1