I have an input data as shown:
df = pd.DataFrame({"colony" : [22, 22, 22, 33, 33, 33],
                  "measure" : [np.nan, 7, 11, 13, np.nan, 9,],
                   "net/gross" : [np.nan, "gross", "net", "gross", "np.nan", "net"]})
df
    colony  measure  net/gross
0   22      NaN      NaN  
1   22      7        gross
2   22      11       net
3   33      13       gross
4   33      NaN      NaN
5   33      9        net
I want to fill the NaN in the measure column with maximum value from each group of the colony, then fill the NaN in the net/gross column with the net/gross value at the row where the measure was maximum (e.g fill the NaN at index 0 with the value corresponding to where the measure was max which is "net") and create a remark column to document all the NaN filled rows as "max_filled" and the other rows as "unchanged" to arrive at an output as below:
   colony  measure  net/gross   remarks
0   22      11      net         max_filled
1   22      7       gross       unchanged
2   22      11      net         unchanged
3   33      13      gross       unchanged
4   33      13      gross       max_filled
5   33      9       net         unchanged
 
     
    