title: Normalizing returns to 100
body: <p>I have the following data set:</p>
  <pre><code>import pandas as pd
  data = [['2020-01-01', 'A', 0.05], ['2020-01-02', 'A', 0.06], ['2020-01-03', 'A', 0.12], ['2020-01-04', 'A', 0.09], ['2020-01-05', 'A', 0.07],   ['2020-01-01', 'B', 0.10], ['2020-01-02', 'B', 0.20], ['2020-01-03', 'B', 0.15], ['2020-01-04', 'B', 0.12], ['2020-01-05', 'B', 0.18],    ['2020-01-01', 'C', 0.05], ['2020-01-02', 'C', 0.11], ['2020-01-03', 'C', 0.18], ['2020-01-04', 'C', 0.09], ['2020-01-05', 'C', 0.22]]
  df = pd.DataFrame(data, columns = ['DATE', 'Stock', 'Return'])
  df
  
  Out[1]:
            DATE Stock  Return
  0   2020-01-01     A    0.05
  1   2020-01-02     A    0.06
  2   2020-01-03     A    0.12
  3   2020-01-04     A    0.09
  4   2020-01-05     A    0.07
  5   2020-01-01     B    0.10
  6   2020-01-02     B    0.20
  7   2020-01-03     B    0.15
  8   2020-01-04     B    0.12
  9   2020-01-05     B    0.18
  10  2020-01-01     C    0.05
  11  2020-01-02     C    0.11
  12  2020-01-03     C    0.18
  13  2020-01-04     C    0.09
  14  2020-01-05     C    0.22
  </code></pre>
  <p>My objective is to normalize the stock return to 100 at the beginning of the time-series, and then adjust it according to the corresponding stock performance in subsequent days. I aim to receive the following (reflected in the column &quot;Price&quot;):</p>
  <pre><code>data2 = [['2020-01-01', 'A', 0.05, 100], ['2020-01-02', 'A', 0.06, 120], ['2020-01-03', 'A', 0.12, 240], ['2020-01-04', 'A', 0.09, 180], ['2020-01-05', 'A', 0.07, 140],   ['2020-01-01', 'B', 0.10, 100], ['2020-01-02', 'B', 0.20, 200], ['2020-01-03', 'B', 0.15, 150], ['2020-01-04', 'B', 0.12, 120], ['2020-01-05', 'B', 0.18, 180],    ['2020-01-01', 'C', 0.05, 100], ['2020-01-02', 'C', 0.11, 220], ['2020-01-03', 'C', 0.18, 360], ['2020-01-04', 'C', 0.09, 180], ['2020-01-05', 'C', 0.22, 440]]
  df2 = pd.DataFrame(data2, columns = ['DATE', 'Stock', 'Return', 'Price'])
  df2
  
  Out[2]:
            DATE Stock  Return  Price
  0   2020-01-01     A    0.05    100
  1   2020-01-02     A    0.06    120
  2   2020-01-03     A    0.12    240
  3   2020-01-04     A    0.09    180
  4   2020-01-05     A    0.07    140
  5   2020-01-01     B    0.10    100
  6   2020-01-02     B    0.20    200
  7   2020-01-03     B    0.15    150
  8   2020-01-04     B    0.12    120
  9   2020-01-05     B    0.18    180
  10  2020-01-01     C    0.05    100
  11  2020-01-02     C    0.11    220
  12  2020-01-03     C    0.18    360
  13  2020-01-04     C    0.09    180
  14  2020-01-05     C    0.22    440
  </code></pre>
  <p>I am aware of a way to reshape the data format from long to wide using the command <code>df = df.reset_index().pivot_table(values='Return', index='DATE', columns='Stock')</code> and then normalize the returns using <code>df = df.pct_change().fillna(0).add(1).cumprod().mul(100).reset_index()</code>, which would yield the following output:</p>
  <pre><code>Out[3]:
  Stock        DATE      A      B      C
  0      2020-01-01  100.0  100.0  100.0
  1      2020-01-02  120.0  200.0  220.0
  2      2020-01-03  240.0  150.0  360.0
  3      2020-01-04  180.0  120.0  180.0
  4      2020-01-05  140.0  180.0  440.0
  </code></pre>
  <p>In this case, however, I want all stocks to be listed in one column, as initially suggested. Is there a way to add the column &quot;Price&quot; and computing the values accordingly for each stock, i.e. for each unique value in the column &quot;Stock&quot;? Is a &quot;for&quot;-loop required for this task?
  Thank you for any suggestions and advices!!</p>