I'm doing a mock financial report. One of the requirements is to find the biggest increase and decrease in profits from 1 month to another as well as the month that this occurred. I've had no trouble finding the min and max changes in profits but have no clue on how to find the month that said changes occur.
here is the header of the data frame
Date Profit/Losses
0 Jan-2010 867884
1 Feb-2010 984655
2 Mar-2010 322013
3 Apr-2010 -69417
4 May-2010 310503
and my current code
diff = [df["Profit/Losses"][i]-df["Profit/Losses"][i-1] for i in range(1,len(df["Profit/Losses"]))]
max_change = max(diff)
min_change = min(diff)
tot_change = sum(diff)
what is the best approach to return the corresponding date value for the maximum and minimum values? For example: I am looking to return that Feb-2012 is the month with the greatest increase in profits.