Skip to content

dataframefilter

dataframefilter

Module for abstract dataframe filter

Classes

DataframeFilter

DataframeFilter()

Bases: ABC

Filter to filter data of a dataframe

Filter to filter data of a dataframe

Source code in niceml/data/datafilters/dataframefilter.py
def __init__(self):
    """Filter to filter data of a dataframe"""

    self.data_description = None
Functions
filter abstractmethod
filter(data)

The filter function takes a dataframe and returns a filtered version of the dataframe. The filter function should return the filtered data.

Parameters:

  • data (DataFrame) –

    pd.DataFrame: Pass the data to be filtered

Returns:

  • DataFrame

    A dataframe with the same columns as data, but only containing rows where the

  • DataFrame

    filter condition is true

Source code in niceml/data/datafilters/dataframefilter.py
@abstractmethod
def filter(
    self,
    data: pd.DataFrame,
) -> pd.DataFrame:
    """
    The filter function takes a dataframe and returns a filtered version of the
    dataframe. The filter function should return the
    filtered data.

    Args:
        data: pd.DataFrame: Pass the data to be filtered

    Returns:
        A dataframe with the same columns as data, but only containing rows where the
        filter condition is true

    """
initialize
initialize(data_description)

The initialize function is called once at the beginning of a run. It can be used to set up any data structures that are needed for the rest of the run. The initialize function takes one argument, which is a data description containing information about what data will be available during this run.

Parameters:

  • data_description (DataDescription) –

    DataDescription: Describe the data that is being passed into the model

Source code in niceml/data/datafilters/dataframefilter.py
def initialize(self, data_description: DataDescription):
    """
    The initialize function is called once at the beginning of a run.
    It can be used to set up any data structures that are needed for the rest of the run.
    The initialize function takes one argument, which is a data description containing
    information about what data will be available during this run.

    Args:
        data_description: DataDescription: Describe the data that is being passed into the model
    """

    self.data_description = data_description