0

I have various time series pandas data frames which look like:

data['F_NQ'] =

OPEN HIGH LOW CLOSE VOL OI P R RINFO DATE
1996-04-10 12450 12494 12200 12275 2282 627 0 0 0 1996-04-11 12200 12360 12000 12195 1627 920 0 0 0

I merged these into one dataframe so that I could select by date using concat mergeData = pd.concat(data, axis=1, keys=data.keys())

Now I can get a slice for a chunk of time: timeSlice = mergeData.loc[startDate:endDate]

my problem is that I am looping over that timeSlice object and selecting a particular day based on the index number...

selectedDay = timeSlice.iloc[n]

I need to know the DATE for the selected row. How do I access that location value? If I provide the location value with: selectedDay = timeSlice.loc[date] the correct information is returned. At the time I'm making the call however I don't know the date. How do I get at that information?

P-Rod
  • 471
  • 1
  • 5
  • 18
  • if the date is your index, you could do `date = timeSlice.iloc[n].name` is that what you are looking for? – Steven G Oct 04 '16 at 00:54

2 Answers2

0

This helped me find the solution... post

I basically need to call: timeSlice.index[-1] to get the last date from whichever time block I've selected.

Community
  • 1
  • 1
P-Rod
  • 471
  • 1
  • 5
  • 18
0

since .iloc[n] return a pandas series with the index has the name, you could get the name of that series doing this :

date = timeSlice.iloc[n].name
Steven G
  • 16,244
  • 8
  • 53
  • 77