def _import_interval(self, records):
        if records == []:
            return pd.Series([]), pd.Series([])
        if records[0].get("start") is not None:
            key = "start"
        elif records[0].get("end") is not None:
            key = "end"
        else:
            message = 'Records must all have a "start" key or must'\
                      ' all have a "end" key.'
            raise ValueError(message)
        try:
            sorted_records = sorted(records, key=lambda x: x[key])
        except KeyError:
            message = 'Records must all have a "start" key or must'\
                      ' all have a "end" key.'
            raise ValueError(message)
        start_limit = sorted_records[0].get(key)
        end_limit = sorted_records[-1].get(key)
        dt_index = pd.date_range(start=start_limit, end=end_limit,
                freq=self.freq)

        # shift index back if the keys given are end dates.
        if key == "end":
            dt_index -= self.freq_timedelta

        data = pd.Series(np.tile(np.nan, dt_index.shape),
                index=dt_index)
        estimated = pd.Series(np.tile(False, dt_index.shape),
                index=dt_index)
        for record in sorted_records:
            dt = record.get(key)
            value = record.get("value")
            est = record.get("estimated")
            if dt is None:
                message = 'Records must all have a "start" key or'\
                          ' must all have a "end" key.'
                raise ValueError(message)
            if key == "end":
                dt -= self.freq_timedelta
            try:
                current_value = data[dt]
            except __HOLE__:
                current_value = None
            if current_value is None:
                message = "Ignoring misaligned data point:"\
                    " (data[{}] = {})".format(dt,value)
                warn(message)
            elif pd.isnull(current_value):
                data[dt] = value
                if est:
                    estimated[dt] = True
            else:
                message = "Ignoring overlapping data point:"\
                    " (data[{}] = {})".format(dt,value)
                warn(message)
        return data, estimated
dataset/ETHPy150Open impactlab/eemeter/eemeter/consumption.py/ConsumptionData._import_interval