// Find the minimum sample period.
// For the sake of speed, only use the first 100 samples.
FWD_DIFF = np.diff(datetime_index.values[:100]).astype(np.float)
MIN_SAMPLE_PERIOD = FWD_DIFF.min() / 1E9
MAX_SAMPLES_PER_PERIOD = _secs_per_period_alias(freq) / MIN_SAMPLE_PERIOD
MAX_SAMPLES_PER_2_PERIODS = MAX_SAMPLES_PER_PERIOD * 2
n_rows_processed = 0
After Change
datetime_index = copy.copy(datetime_index)
ts = datetime_index[0] // "ts" = timestamp
// Calculate timezone offset relative to UTC
tz_offset = ts.replace(tzinfo=None) - ts.tz_convert("UTC").replace(tzinfo=None)
datetime_index = datetime_index.tz_convert("UTC") + tz_offset
// We end up with a datetime_index being tz-aware, localised to UTC
// but offset so that the UTC time is the same as the local time
// e.g. if, prior to conversion,
// datetime_index[0] = 12:00-04:00 US/Eastern
// then after conversion:
// datetime_index[0] = 12:00+00:00 UTC
periods = pd.period_range(datetime_index[0], datetime_index[-1], freq=freq)
// Declare and initialise some constants and variables used
// during the loop...
// Find the minimum sample period.
MIN_SAMPLE_PERIOD = int(sample_period(datetime_index))
MAX_SAMPLES_PER_PERIOD = int(_secs_per_period_alias(freq) / MIN_SAMPLE_PERIOD)
MAX_SAMPLES_PER_2_PERIODS = MAX_SAMPLES_PER_PERIOD * 2
n_rows_processed = 0
boundaries = {}
for period in periods: