def make_time_index_intervals(twitter_df, col='date', start=None, end=None,
    freq='CBH', num_offset=1):
    """Takes a df, rounds first timestamp down to nearest hour, last timestamp rounded up to hour.
    Creates 30 minute intervals based that encompass all data."""
    import pandas as pd
    if freq == 'CBH':
        freq = pd.offsets.CustomBusinessHour(n=num_offset, start='09:30',
            end='16:30')
        ofst = pd.offsets.CustomBusinessHour(n=num_offset, start='09:30',
            end='16:30')
        ofst_early = pd.offsets.CustomBusinessHour(n=-num_offset, start=
            '09:30', end='16:30')
    if freq == 'T':
        ofst = pd.offsets.Minute(n=num_offset)
        ofst_early = pd.offsets.Minute(n=-num_offset)
    if freq == 'H':
        ofst = pd.offsets.Hour(n=num_offset)
        ofst_early = pd.offsets.Hour(n=-num_offset)
    if start is None:
        start_idx = ofst.rollback(twitter_df[col].iloc[0])
    else:
        start_idx = pd.to_datetime(start)
    if end is None:
        end_idx = ofst.rollforward(twitter_df[col].iloc[-1])
    else:
        end_idx = pd.to_datetime(end)
    time_range = pd.date_range(start=start_idx, end=end_idx, freq=freq)
    time_intervals = pd.interval_range(start=start_idx, end=end_idx, freq=
        freq, name='interval_index', closed='left')
    return time_intervals
