Using pandas DataFrame with resample works too. OP data, but change "some data here" to "abcd".
>>> import datetime as DT >>> raw = ("2010-08-01", ... "2010-06-25", ... "2010-07-01", ... "2010-07-08") >>> transactions = [(DT.datetime.strptime(datestring, "%Y-%m-%d"), data) for ... datestring, data in zip(raw,'abcd')] [(datetime.datetime(2010, 8, 1, 0, 0), 'a'), (datetime.datetime(2010, 6, 25, 0, 0), 'b'), (datetime.datetime(2010, 7, 1, 0, 0), 'c'), (datetime.datetime(2010, 7, 8, 0, 0), 'd')]
Now try using pandas. First create a DataFrame by naming the columns and setting the indexes on the dates.
>>> import pandas as pd >>> df = pd.DataFrame(transactions, ... columns=['date','data']).set_index('date') data date 2010-08-01 a 2010-06-25 b 2010-07-01 c 2010-07-08 d
Now use Offset Aliases every 2 weeks starting on Sunday and combine the results.
>>> fortnight = df.resample('2W-SUN').sum() data date 2010-06-27 b 2010-07-11 cd 2010-07-25 0 2010-08-08 a
Now check the data as needed in a weekly start
>>> fortnight.loc['2010-06-27']['data'] b
or index
>>> fortnight.iloc[0]['data'] b
or indices
>>> data = fortnight.iloc[:2]['data'] b date 2010-06-27 b 2010-07-11 cd Freq: 2W-SUN, Name: data, dtype: object >>> data[0] b >>> data[1] cd