title: Python pandas resample takes too much memory
body: <p>I have a time series of firm fundamental data like market value, closing price indexed by date, and cusip with weekly frequency. I would like to resample it to get data with monthly frequency but the problem is that my code takes too much memory and too much time for a very little amount of data. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>def getMonthlyData(start=(datetime.now()-relativedelta(years=5)),end=datetime.now()):
      _data=getWeeklyData(start,end)
      _startTime=datetime.now()
      _data=_data.unstack('Cusip').resample('M',how=(lambda x:x[-1])).stack('Cusip')
      _endTime=datetime.now()
      print("Time Taken to Resample Data : " + str(_endTime - _startTime))
      _data.sort_index(ascending=[False,True],inplace=True)
      return _data
  </code></pre>
  
  <p>The <code>getWeeklyData()</code> function returns the data quickly (if, say, I pull in about two months of data) but after that the program just sort of hangs and the memory consumption goes up significantly.</p>
  
  <p>How can I improve it?</p>