title: How to calculate monthly return from daily price data?
body: <pre><code>In [27]: df 
  Out[27]:   Date                  MSCI USA/CONSUMER DISCR
  3958 2018-07-02                  325.810
  3959 2018-07-03                  323.680
  3960 2018-07-05                  325.550
  3961 2018-07-06                  328.050
  3962 2018-07-09                  331.890
  3963 2018-07-10                  332.650
  3964 2018-07-11                  331.740
  3965 2018-07-12                  333.910
  3966 2018-07-13                  334.850
  3967 2018-07-16                  335.290
  3968 2018-07-17                  335.990
  3969 2018-07-18                  335.740
  3970 2018-07-19                  334.870
  3971 2018-07-20                  333.240
  3972 2018-07-23                  332.690
  3973 2018-07-24                  331.600
  3974 2018-07-25                  333.930
  3975 2018-07-26                  332.100
  </code></pre>
  
  <p>I have daily price data which I want to calculate monthly return. What makes this problem hard is that my data is based on the stock market trading day, not the actual dates. </p>
  
  <p>First day of the month in my data is not necessarily day 1 of the month (<code>2018-07-02</code> as opposed to <code>2018-07-01</code>.) Same for the last day of the month (it's not necessarily the actual last day of the month).</p>
  
  <p>I have tried:</p>
  
  <pre><code>g = df.groupby(pd.Grouper(freq = 'M'))
  g.sum()
  2018-06-30    6884.610
  2018-07-31    5973.580.
  g_date = g.index
  </code></pre>
  
  <p>which is not what I want because <code>2018-07-31</code> does not exist in my original data.</p>
  
  <p>I would very appreciate if someone could share their advice.</p>
  
  <p>Thank you very much.</p>