code: def square_off(series, time_delta=None, transition_seconds=1):
      if time_delta:
          if isinstance(time_delta, (int, float)):
              time_delta = datetime.timedelta(0, time_delta)
          new_times = series.index + time_delta
      else:
          diff = np.diff(series.index)
          time_delta = np.append(diff, [diff[-1]])
          new_times = series.index + time_delta
          new_times = pd.DatetimeIndex(new_times) - datetime.timedelta(0, transition_seconds)
      return pd.concat([series, pd.Series(series.values, index=new_times)]).sort_index()