Pandas Series Resampling: How do I get moves based on certain previous changes?
Question: 
    import pandas as pd 
    import numpy as np 
    import datetime as dt
    
    # Create Column names
    col_names = ['930', '931', '932', '933', '934', '935']
    # Create Index datetimes 
    idx_names = pd.date_range(start = dt.datetime(2011, 1, 1), periods = 10, freq= 'D')
    
    # Create dataframe with previously created column names and index datetimes
    df1 = pd.DataFrame(np.random.randn(10, 6), columns=col_names, index=idx_names)
    
    # Change the column names from strings to datetimes.time() object
    df1.columns = [dt.datetime.strptime(x, '%H%M').time() for x in df1.columns]
    
    # This step and the next step changes the dataframe into a chronological timeseries
    
    df2 = df1.T.unstack()
    df2.index = [dt.datetime.combine(x[0], x[1]) for x in df2.index.tolist()]
    
    # Show the series
    df2
    

Question: What is the most pythonic/pandas-thonic way to create a specific
list? This list would say 'Every time the difference between 9:32 and 9:34 is
between 0 and .50, what is the difference between 9:34 and the next day's
9:34.

I was doing this with the numbers in a dataframe format (dates along the
x-axis and times along the y-axis) and I would say something like (below is
pseudo-code, above is not pseudo-code):

    
    
    # Create a column with wrong answers and right answers
    df['Today 934 minus yesterday 934'] = df[934] - df[934].shift(1)
    
    # Boolean mask were condition 1 (diff > 0) and condition 2 (diff < .5) are true
    mask = (df[934].shift(1) - df[932].shift(1) > 0) & (df[934].shift(1) - df[932].shift(1) < .5)
    # Apply the boolean mask to the dataframe. This is will remove all the answers
    # I dont want from the df['Today 934 minus yesterday 934'] column
    df2 = df[mask]
    
    # Only the answers I want:
    answers = df['Today 934 minus yesterday 934']
    


Answer: My attempt, basically a filled in version of your pseudo-code. Someone else
may have a cleaner approach.

    
    
    mask1 = (df2.index.hour == 9) & (df2.index.minute == 34)
    mask2 = (df2.index.hour == 9) & (df2.index.minute == 32)
    
    diff_934 = df2[mask1] - df2[mask1].shift(-1)
    diff_934 = diff_934[diff_934.index.minute == 34]
    
    diff_932 = df2[mask1|mask2]  - df2[mask1|mask2].shift(-1)
    diff_932 = diff_932[diff_932.index.minute == 34]
    diff_932 = diff_932[(diff_932 > 0) & (diff_932 < .5)]
    
    answer = diff_934.reindex(diff_932.index)
    
    
    In [116]: answer
    Out[116]: 
    2011-01-02 09:34:00   -0.874153
    2011-01-08 09:34:00    0.186254
    dtype: float64
    

