Skip to content

Slicing

Slicing

SliceRows

Bases: TransformerStep

Slice portion of the run-to-failure cycle

Parameters:

Name Type Description Default
initial Union[int, RelativePosition]

Initial position of the slice, default RelativeToStart(0)

RelativeToStart(0)
final Union[int, RelativePosition]

Final position of the slice, default RelativeToEnd(0)

RelativeToEnd(0)
Source code in ceruleo/transformation/features/slicing.py
class SliceRows(TransformerStep):
    """
    Slice portion of the run-to-failure cycle

    Parameters:
        initial: Initial position of the slice, default RelativeToStart(0)
        final: Final position of the slice, default RelativeToEnd(0)
    """

    def __init__(
        self,
        initial: Union[int, RelativePosition] = RelativeToStart(0),
        final: Union[int, RelativePosition] = RelativeToEnd(0),
        *args,
        **kwargs
    ):

        super().__init__(*args, **kwargs)

        self.initial = initial
        self.final = final

    def transform(self, X: pd.DataFrame) -> pd.DataFrame:
        """ 
        Slice the run-to-failure cycle

        Parameters:
            X: Input dataframe

        Returns:
            A dataframe with the sliced run-to-failure cycle
        """
        if isinstance(self.initial, RelativePosition):
            initial = self.initial.get(X.shape[0])
        else:
            initial = self.initial
        if isinstance(self.final, RelativePosition):
            final = self.final.get(X.shape[0])
        else:
            final = self.final

        return X.iloc[initial:final, :].copy()

transform(X)

Slice the run-to-failure cycle

Parameters:

Name Type Description Default
X DataFrame

Input dataframe

required

Returns:

Type Description
DataFrame

A dataframe with the sliced run-to-failure cycle

Source code in ceruleo/transformation/features/slicing.py
def transform(self, X: pd.DataFrame) -> pd.DataFrame:
    """ 
    Slice the run-to-failure cycle

    Parameters:
        X: Input dataframe

    Returns:
        A dataframe with the sliced run-to-failure cycle
    """
    if isinstance(self.initial, RelativePosition):
        initial = self.initial.get(X.shape[0])
    else:
        initial = self.initial
    if isinstance(self.final, RelativePosition):
        final = self.final.get(X.shape[0])
    else:
        final = self.final

    return X.iloc[initial:final, :].copy()