I have a dataframe:
df = pd.DataFrame({ 'x': [3,4,5,8,10,11,12,13,15,16,18,21,24,25], 'a': [10,9,16,4,21,5,3,17,11,5,21,19,3,9] }) df Out[30]: a x 0 10 3 1 9 4 2 16 5 3 4 8 4 21 10 5 5 11 6 3 12 7 17 13 8 11 15 9 5 16 10 21 18 11 19 21 12 3 24 for every "x" value I should subtract a certain number (say 3), and then find a maximum "a" value where x is in a range from x-3 to x. For example: index, x, x-3, max(a) where x is between x-3 and x 0, 3, 0, 10 1, 4, 1, 10 2, 5, 2, 16 3, 8, 5, 16 4, 10, 7, 21 ... "x" is incremental, "a" is random How to find max "a" values? -- https://mail.python.org/mailman/listinfo/python-list