I have got a Dataframe , i want to find which store has good quarterly growth rate in Q3
Store Date Weekly_Sales
0 1 2012-03-31 18951097.69
1 1 2012-06-30 21036965.58
2 1 2012-09-30 18633209.98
3 1 2012-12-31 9580784.77
4 2 2012-03-31 22543946.63
5 2 2012-06-30 25085123.61
6 2 2012-09-30 22396867.61
7 2 2012-12-31 11470757.52
I managed to loop through the items and got this far but after that i am unable to find any way. I think i have to go to the next value and get the sales and then add it,but i m not sure how to do that. I want to compare index 1 and 2 of Store 1 and find growth rate , again doing the same thing for Store 2 here index 5 and 6 and So on as i have total 45 Stores available.
new_df = []
for index, row in monthly_sales.iterrows():
if index == 1: ----Not sure what condition to put here
q2 = row['Weekly_Sales']
q3 = row['Weekly_Sales']
growth_rate = (q3 - q2)/(q2*100)
new_df.append([row['Store'],growth_rate])
#print(index, row['Store'],row['Date'], row['Weekly_Sales'])
#exit;
new_df
Output can be something like this
Store Growth Rate
0 1 6.67890
1 2 5.54327
I am a newbie to Python and Pandas.