def filter_by_period(self, period):
        """ Return a new ConsumptionData instance within the period.

        Parameters
        ----------
        period : eemeter.evaluation.Period
            Period within which to get ConsumptionData

        Returns
        -------
        consumption_data : eemeter.consumption.ConsumptionData
            ConsumptionData instance holding data within the requested period.
        """
        filtered_data = None
        filtered_estimated = None
        if period.start is None and period.end is None:
            filtered_data = self.data.copy()
            filtered_estimated = self.estimated.copy()
        elif period.start is None and period.end is not None:
            filtered_data = self.data[:period.end].copy()
            filtered_estimated = self.estimated[:period.end].copy()
        elif period.start is not None and period.end is None:
            filtered_data = self.data[period.start:].copy()
            filtered_estimated = self.estimated[period.start:].copy()
        else:
            filtered_data = self.data[period.start:period.end].copy()
            filtered_estimated = self.estimated[period.start:period.end].copy()
        if self.freq is None and filtered_data.shape[0] > 0:
            filtered_data.iloc[-1] = np.nan
            filtered_estimated.iloc[-1] = np.nan
        filtered_consumption_data = ConsumptionData(
                records=None,
                fuel_type=self.fuel_type,
                unit_name=self.unit_name,
                data=filtered_data,
                estimated=filtered_estimated)
        return filtered_consumption_data
dataset/ETHPy150Open impactlab/eemeter/eemeter/consumption.py/ConsumptionData.filter_by_period/original