def METHOD_NAME(self, Z):
    """Logic internal to the algorithm for transforming the input series.
    Parameters
    ----------
    Z : pd.Series
    Returns
    -------
    pd.Series
    """
    # warn if nan values in Series, as user might mix them
    # up with outliers otherwise
    if Z.isnull().values.any():
        warnings.warn(
            """Series contains nan values, more nan might be
            added if there are outliers""",
            stacklevel=2,
        )
    cv = SlidingWindowSplitter(
        fh=0,
        window_length=self.window_length,
        step_length=1,
        start_with_window=True,
    )
    half_window_length = int(self.window_length / 2)
    Z = _hampel_filter(
        Z=Z,
        cv=cv,
        n_sigma=self.n_sigma,
        half_window_length=half_window_length,
        k=self.k,
    )
    # data post-processing
    if self.return_bool:
        Z = Z.apply(lambda x: bool(np.isnan(x)))
    return Z