Get max value in previous rows for matching rows
Say I have a dataframe that records temperature measurements for various sensors: import pandas as pd df = pd.DataFrame({‘sensor’: [‘A’, ‘C’, ‘A’, ‘C’, ‘B’, ‘B’, ‘C’, ‘A’, ‘A’, ‘A’], ‘temperature’: [4.8, 12.5, 25.1, 16.9, 20.4, 15.7, 7.7, 5.5, 27.4, 17.7]}) I would like to add a column max_prev_temp that will show the previous maximum temperature… Read More Get max value in previous rows for matching rows