Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monthly = ['2017-04-01', '2017-05-01', '2017-06-01', '2017-07-01',
- '2017-08-01', '2017-09-01', '2017-10-01', '2017-11-01',
- '2017-12-01', '2018-01-01', '2018-02-01', '2018-03-01',
- '2018-04-01', '2018-05-01', '2018-06-01', '2018-07-01',
- '2018-08-01', '2018-09-01', '2018-10-01']
- prev_suffix = []
- _flag = False
- to_read = []
- to_remove = []
- kokaku_duration = cols['PARAMS']['KOKAKU_DAYS']
- for m in monthly:
- n_acc_list = []
- # determine month suffix
- d_end = pd.to_datetime(m, format='%Y-%m-%d')
- d_begin = d_end - pd.DateOffset(days=int(kokaku_duration - 1))
- date_suffix = list(pd.date_range(start=d_begin, end=d_end, freq='D').strftime('%Y%m').drop_duplicates())
- for _suffix in date_suffix:
- if _flag:
- to_read = list(set(date_suffix) - set(prev_suffix))
- to_remove = list(set(date_suffix) ^ set(prev_suffix))
- to_remove = list(list(set(to_read) - set(to_remove)) + list(set(to_remove)-set(to_read)))
- else:
- to_read = date_suffix
- # update state
- prev_suffix = date_suffix
- _flag = True
- print(_suffix)
- print('to read: {}'.format(to_read))
- print('to delete: {}\n'.format(to_remove))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement