Replace column values within a groupby and condition
问题 I have a dataframe that I want to find the minimum value of a column within a group, and then based on that row, update the values of some of the other columns. The following code does what I want: import pandas as pd df = pd.DataFrame({'ID': [1,1,1,2,2,2,], 'Albedo': [0.2, 0.4, 0.5, 0.3, 0.5, 0.1], 'Temp' : [20, 30, 15, 40, 10, 5], 'Precip': [200, 100, 150, 60, 110, 45], 'Year': [1950, 2000, 2004, 1999, 1976, 1916]}) #cols to replace values for cols = ['Temp', 'Precip', 'Year'] final = pd