def _import_arbitrary_end(self, records):
        if records == []:
            return pd.Series([]), pd.Series([])
        try:
            sorted_records = sorted(records, key=lambda x: x["end"])
        except __HOLE__:
            message = 'Records must all have a "end" key.'
            raise ValueError(message)
        end_datetimes = [r["end"] for r in sorted_records]
        values = [r.get("value") for r in sorted_records[1:]]
        estimateds = [bool(r.get("estimated")) for r in sorted_records[1:]]

        # insert start value to if first record has a start date
        first_start = sorted_records[0].get("start")
        if first_start is not None:
            end_datetimes.insert(0,first_start)
            values.insert(0,sorted_records[0].get("value"))
            estimateds.insert(0,bool(sorted_records[0].get("estimated")))
        values.append(np.nan)
        estimateds.append(False)
        dt_index = pd.DatetimeIndex(end_datetimes)
        data = pd.Series(values, index=dt_index)
        estimated = pd.Series(estimateds, index=dt_index)
        return data, estimated
dataset/ETHPy150Open impactlab/eemeter/eemeter/consumption.py/ConsumptionData._import_arbitrary_end