I tried to create multi index data frame, it should work fine using diff() function.
using newdf.groupby('machine_id').event_date.diff() suggested by ATL should work fine.
o
# hierarchical indices and columns
index = pd.MultiIndex.from_product([[598, 615, 721], [43, 43, 45]],
names=['machine_id', 'prod_category_id'])
# mock some data
data = ['2017-03-20 12:00:00','2017-03-29 01:00:00','2017-04-29 01:00:00',
'2017-03-30 02:00:00', '2017-04-29 02:00:00','2017-05-29 12:00:00',
'2017-10-30 02:00:00', '2017-11-29 02:00:00', '2017-11-29 04:00:00']
# create the DataFrame
newdf = pd.DataFrame(data, index=index)
newdf.columns = ['event_date']
newdf['event_date'] = pd.to_datetime(newdf['event_date'])
newdf.groupby(level=0)['event_date'].diff()
