Pandas diff() functionality on two columns in a dataframe
You can shift A column first:
df['A'].shift(-1) - df['B']
I have a data frame in which column A is the start time of an activity and column B is the finish time of that activity, and each row represents an activity (rows are arranged chronologically).  I want to compute the difference in time between the end of one activity and the start of the next activity, i.e. df[i+1][A] - df[i][B].
Is there a Pandas function to do this (the only thing I can find is diff(), but that only appears to work on a single column).