title: How to use Groupby function to find a moving average?
body: <p>So I have a CSV file with minute stock data. Though I am looking to find the 20 day moving average rather than the 20 period moving average. So I am trying to use groupby inorder to group the data into day data. But then I am finding issues when I using the .rolling function. The code looks like this:</p>
  <pre><code>import pandas as pd
  ticker = 'MSFT'
  df = pd.read_csv('/Volumes/Seagate Portable/S&amp;P 500 List/{}.txt'.format(ticker))
  df.columns = ['Extra', 'Dates', 'Open', 'High', 'Low', 'Close', 'Volume']
  df.Dates = pd.to_datetime(df.Dates)
  df.set_index('Dates', inplace=True)
  df = df.between_time('9:30', '16:00')
  df.groupby(pd.Grouper(freq='D')).rolling(window=20).mean()
  df.drop(['Extra', 'Open', 'High', 'Volume', 'Low'], axis=1, inplace=True)
  </code></pre>
  <p>Though I am getting the error <code>AttributeError: 'BinGrouper' object has no attribute '_groupings'</code>
  My hope is the output looks like:</p>
  <pre><code>                     Close  MA MSFT
  Dates       
  2020-01-02 09:30:00 158.610 158.91601
  2020-01-02 09:31:00 158.380 158.88851
  2020-01-02 09:32:00 158.620 158.87451
  2020-01-02 09:33:00 158.692 158.85911
  2020-01-02 09:34:00 158.910 158.85411
  </code></pre>
  <p>But rather than the 20 minute moving average, the 20 day moving average. Though I am also trying to do it where the minute data remains unchanged so that MA MSFT will have the same value for a days worth of data then change for the following day and so on. So for the example above say that the 20 moving average was 158 then it would look like:</p>
  <pre><code>                     Close  MA MSFT
  Dates       
  2020-01-02 09:30:00 158.610 158
  2020-01-02 09:31:00 158.380 158
  2020-01-02 09:32:00 158.620 158
  2020-01-02 09:33:00 158.692 158
  2020-01-02 09:34:00 158.910 158
  </code></pre>
  <p>Then the next days worth of day data would be (if the MA was 159):</p>
  <pre><code>                   Close    MA MSFT
  Dates       
  2020-01-03 09:30:00 158.610 159
  2020-01-03 09:31:00 158.380 159
  2020-01-03 09:32:00 158.620 159
  2020-01-03 09:33:00 158.692 159
  2020-01-03 09:34:00 158.910 159
  </code></pre>