code: def average_temperature(self, unit='kelvin'):
          
          if unit not in ('kelvin', 'celsius', 'fahrenheit'):
              raise ValueError("Invalid value for parameter 'unit'")
          average = self._average(self._purge_none_samples(
                                                    self.temperature_series()))
          if unit == 'kelvin':
              result = average
          if unit == 'celsius':
              result = temputils.kelvin_to_celsius(average)
          if unit == 'fahrenheit':
              result = temputils.kelvin_to_fahrenheit(average)
          return result
docs: Returns the average value in the temperature series
          
          :param unit: the unit of measure for the temperature values. May be
              among: '*kelvin*' (default), '*celsius*' or '*fahrenheit*'
          :type unit: str
          :returns: a float
          :raises: ValueError when invalid values are provided for the unit of
              measure or the measurement series is empty