title: How to find percent change by row within groups python pandas
body: <p>I have a sample of my dataframe as follows:</p>
  <pre><code>data = {'retailer': [2, 2, 2, 2, 2, 5, 5, 5, 5, 5],
          'store': [1, 1, 1, 1, 1, 7, 7, 7, 7, 7],
          'week':[2021110701, 2021101301, 2021100601, 2021092901, 2021092201, 2021110701, 2021101301, 2021100601, 2021092901, 2021092201],
          'dollars': [353136.2, 379263.8, 507892.1, 491528.2, 503602.8, 435025.2, 406698.5, 338383.5, 360845.1, 372385.2]
         }
  data = pd.DataFrame(data)
  </code></pre>
  <p>I have sorted my columns by doing</p>
  <pre><code>data = data.sort_values(['retailer', 'store', 'week'], ascending=(True, True, False))
  </code></pre>
  <p>I would like to find the percent different in dollars between each row WITHIN each group...so essentially group by retailer, then store and then find the percent difference between the rows for 'dollars' between the week and the week below it, and then save the value in a column next to the dollars.</p>
  <p>Basically have the output look like:</p>
  <pre><code>data = {'retailer': [2, 2, 2, 2, 2, 5, 5, 5, 5, 5],
          'store': [1, 1, 1, 1, 1, 7, 7, 7, 7, 7],
          'week':[2021110701, 2021101301, 2021100601, 2021092901, 2021092201, 2021110701, 2021101301, 2021100601, 2021092901, 2021092201],
          'dollars': [353136.2, 379263.8, 507892.1, 491528.2, 503602.8, 435025.2, 406698.5, 338383.5, 360845.1, 372385.2],
          'pc_diff': [-0.06889030801252315, -0.2532591075939161, 0.03329188437204613, -0.02397643539710259, 'NaN', 0.06965036753270545, 0.20188632128930636, -0.062247208012523876, -0.030989684874694362, 'NaN']
         }
  data = pd.DataFrame(data)
  
  </code></pre>
  <p>So for retailer 2, store 1 trying to find the percent difference between week <code>2021110701</code> and <code>2021101301</code> which would be <code>(353136.2 - 379263.8)/379263.8</code>.</p>
  <p>The NAs exist because there is no row below that one so there is nothing to find the percent change between (if that makes sense). Is there a way I can do this/is there a pandas equivalent of using a lag function?</p>