code: def apply(self, func, mapping=None, new_dtype=None, **kwargs):
          if callable(func):
              return Series(func(self.values,
                                 weld_type=self.weld_type,
                                 **kwargs),
                            self.index,
                            self.dtype,
                            self.name)
          elif isinstance(func, str):
              check_type(mapping, dict)
              check_dtype(new_dtype)
              default_mapping = {'self': self.values}
              if mapping is None:
                  mapping = default_mapping
              else:
                  mapping.update(default_mapping)
              if new_dtype is None:
                  new_dtype = self.dtype
              return Series(weld_udf(func,
                                     mapping),
                            self.index,
                            new_dtype,
                            self.name)
          else:
              raise TypeError('Expected function or str defining a weld_template')