-- Edit I noticed I had inputted times not as I intended. I converted the after 12pm times to the 24 hour clock convention. However, unutbu's answer should still be clear.

-- 2nd Edit. I changed the data to make a better example.

Below is a a time series indexed by date. I want to do an aggregation starting from a start\_datetime and continuing its aggregation according to the timedelta below (9.5 hours = 34200 seconds).

```
def main():

    # start_datetime = datetime.datetime(2013, 1, 1, 8)
    # end_datetime = datetime.datetime(2013, 1, 1, 5, 30)
    s = pd.Series(
        np.arange(2, 10),
        pd.to_datetime([
            '20130101 7:34:04', '20130101 8:34:08', '20130101 10:34:08',
            '20130101 12:34:15', '20130101 13:34:28', '20130101 12:34:54',
            '20130101 14:34:55', '20130101 17:29:12']))

    print(s)
    bar_size = datetime.timedelta(seconds=60*60*9.5)
    time_group = pd.Grouper(
        freq=pd.Timedelta(bar_size), closed='left', label='right')
    foobar = s.groupby(time_group).agg(np.sum)
    print(foobar)

if __name__ == "__main__":
    main()

```

Running the above code will output the following:

```
2013-01-01 09:30:00     5
2013-01-01 19:00:00    39
Freq: 570T, dtype: int64

```

The pandas internals decides to starts grouping from midnight instead of 8:00 am. I cannot find a way to force the dataframe to begin grouping at 8:00 am. Does anyone have a solution using pandas functions?