`end=None`. If this df starts with an open-ended good section
then the first TimeFrame will have `start=None`.
index = df.dropna().index
timedeltas_sec = timedelta64_to_secs(diff(index.values))
timedeltas_check = timedeltas_sec <= max_sample_period
timedeltas_check = concatenate(
[[previous_chunk_ended_with_open_ended_good_section],
timedeltas_check])
transitions = diff(timedeltas_check.astype(np.int))
good_sect_starts = index[:-1][transitions == 1]
good_sect_ends = index[:-1][transitions == -1]
good_sect_ends = list(good_sect_ends)
good_sect_starts = list(good_sect_starts)
// Use look_ahead to see if we need to append a
// good sect start or good sect end.
look_ahead_valid = look_ahead is not None and not df.look_ahead.empty
if look_ahead_valid:
look_ahead_timedelta = df.look_ahead.dropna().index[0] - index[-1]
look_ahead_gap = look_ahead_timedelta.total_seconds()
if timedeltas_check[-1]: // current chunk ends with a good section
if not look_ahead_valid or look_ahead_gap > max_sample_period:
// current chunk ends with a good section which needs to
// be closed because next chunk either does not exist
// or starts with a sample which is more than max_sample_period
// away from df.index[-1]
good_sect_ends += [index[-1]]
elif look_ahead_valid and look_ahead_gap <= max_sample_period:
// Current chunk appears to end with a bad section
// but last sample is the start of a good section
good_sect_starts += [index[-1]]
// Work out if this chunk ends with an open ended good section
if len(good_sect_ends) == 0:
ends_with_open_ended_good_section = (
len(good_sect_starts) > 0 or
previous_chunk_ended_with_open_ended_good_section)
elif len(good_sect_starts) > 0:
After Change
`end=None`. If this df starts with an open-ended good section
then the first TimeFrame will have `start=None`.
index = df.dropna().sort_index().index
timedeltas_sec = timedelta64_to_secs(diff(index.values))
timedeltas_check = timedeltas_sec <= max_sample_period
timedeltas_check = concatenate(
[[previous_chunk_ended_with_open_ended_good_section],
timedeltas_check])
transitions = diff(timedeltas_check.astype(np.int))
good_sect_starts = index[:-1][transitions == 1]
good_sect_ends = index[:-1][transitions == -1]
good_sect_ends = list(good_sect_ends)
good_sect_starts = list(good_sect_starts)
// Use look_ahead to see if we need to append a
// good sect start or good sect end.
look_ahead_valid = look_ahead is not None and not df.look_ahead.empty
if look_ahead_valid:
look_ahead_timedelta = df.look_ahead.dropna().index[0] - index[-1]
look_ahead_gap = look_ahead_timedelta.total_seconds()
if timedeltas_check[-1]: // current chunk ends with a good section
if not look_ahead_valid or look_ahead_gap > max_sample_period:
// current chunk ends with a good section which needs to
// be closed because next chunk either does not exist
// or starts with a sample which is more than max_sample_period
// away from df.index[-1]
good_sect_ends += [index[-1]]
elif look_ahead_valid and look_ahead_gap <= max_sample_period:
// Current chunk appears to end with a bad section
// but last sample is the start of a good section
good_sect_starts += [index[-1]]
// Work out if this chunk ends with an open ended good section
if len(good_sect_ends) == 0:
ends_with_open_ended_good_section = (
len(good_sect_starts) > 0 or
previous_chunk_ended_with_open_ended_good_section)
elif len(good_sect_starts) > 0: