I want to identify groups of continuos dates (no time gaps) in datetime index in a similar way to this question
so let's say I create a list of datetime with gaps
ref=pd.date_range(start='2014-01-01 08:00:00',end='2014-01-01 09:30:00',freq='10 min')
ref=ref.delete([3,4])
'''how should I define my lambda function in order to iterate on consecutive datetime elements'''
ranges = []
for k, g in groupby(enumerate(ref), lambda (i,x):i-x):
group = map(itemgetter(1), g)
ranges.append((group[0], group[-1]))
So the result should be something like
[('2014-01-01 08:00:00','2014-01-01 08:20:00'),('2014-01-01 08:50:00',
'2014-01-01 09:30:00')]
I know how to do it with list comprehension and for loops but I was looking for something more efficient like this itertools