In R's xts package there is a function called endpoints
which given a xts object will return a index for when a given month, week, or any user specified frequency back. How can one do this in pandas with python?
R:
endpoints(xts.object, "frequency")
Python:
from matplotlib.pylab import *
from pandas.io.data import DataReader
from datetime import datetime
symbols = ["SPY","IEF"]
data_holder = DataReader(symbols, "yahoo",datetime(2001,1,1))
adj_close = data_holder["Adj Close"] #adjusted close data
adj_close = adj_close.dropna() #drop NAs
adj_close.head() #inspect elements
I understand that resampling function in python with "M"
as parameter will get me the monthly data. But is there a way to get an array of index such that each of these indexes reference a row in the dataframe which is a month end date?
So a concrete example and I am using pseudo-code:
month_ends = adj_close.someFunction("months") #gives me the index of each month ends
month_ends.head()
[22,41,62..etc]
adj_close[month_ends,] #should give me the same thing as resampled("M")