Hi I am really new to Pandas. I tried to figure out what's going on with the datatype here but so far I am unable to go very far.
What I intend to do is very simple indeed. I am searching for the index of a DataFrame data2 with the nearest time to the target time in data1.
Since data1 and data2 are very similar, just that there are some minor time difference due to slightly different sampling rate, I attach only the sample of data1 here:

I did something like this in the search of closest match data by comparing the timestamp in data2 to timestamp in data1:
idxcollect = []
for loopidx, tstamploop in enumerate( tstamp_data1[820990:821000] ):
idxtemp = data2[ data2['timestamp'] == tstamp_data2.asof(tstamploop) ].index
delta1 = np.abs( data2.timestamp[idxtemp] - data1.timestamp[loopidx] )
delta2 = np.abs( data2.timestamp[idxtemp + 1] - data1.timestamp[loopidx] )
if delta1.iloc[0] < delta2.iloc[0]:
idxreturn = idxtemp
idxcollect.append( idxreturn )
else:
idxreturn = idxtemp + 1
idxcollect.append( idxreturn )
tstamp_data1 / tstamp_data2 is of dtype('<M8[ns]'), calculated from epoch time in data1 and data2.
The output I got is:
[Int64Index([809498], dtype='int64'), Int64Index([809499], dtype='int64'), Int64Index([809500], dtype='int64'), Int64Index([809501], dtype='int64'), Int64Index([809502], dtype='int64'), Int64Index([809503], dtype='int64'), Int64Index([809509], dtype='int64'), Int64Index([809513], dtype='int64'), Int64Index([809521], dtype='int64'), Int64Index([809533], dtype='int64')]
What I would like to do is to slice corresponding rows of data2 from the indices found through the operation above, with something as simple as:
data2.ix[ idxcollect[:11] ]
However with the Int64Index format, I am unable to do anything as simple as what I wanted to. Is there any way out? Thank you for your time and attention and help!!
