timeseries_shaper.filter.boolean_filter

 1import pandas as pd
 2from ..base import Base
 3
 4class IsDeltaFilter(Base):
 5    """
 6    Provides class methods for filtering is_delta columns in a pandas DataFrame.
 7    """
 8
 9    @classmethod
10    def filter_is_delta_true(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
11        """Filters rows where 'is_delta' is True."""
12        # No need for instance, working directly on class level
13        return dataframe[dataframe[column_name] == True]
14
15    @classmethod
16    def filter_is_delta_false(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
17        """Filters rows where 'is_delta' is False."""
18        return dataframe[dataframe[column_name] == False]
19
20
21class BooleanFilter(Base):
22    """
23    Provides class methods for filtering boolean columns in a pandas DataFrame,
24    particularly focusing on status changes.
25    """
26    
27    @classmethod
28    def filter_falling_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
29        """Filters rows where 'value_bool' changes from True to False."""
30        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
31        return dataframe[(dataframe['previous_value_bool'] == True) & (dataframe[column_name] == False)]
32
33    @classmethod
34    def filter_raising_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
35        """Filters rows where 'value_bool' changes from False to True."""
36        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
37        return dataframe[(dataframe['previous_value_bool'] == False) & (dataframe[column_name] == True)]
class IsDeltaFilter(timeseries_shaper.base.Base):
 5class IsDeltaFilter(Base):
 6    """
 7    Provides class methods for filtering is_delta columns in a pandas DataFrame.
 8    """
 9
10    @classmethod
11    def filter_is_delta_true(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
12        """Filters rows where 'is_delta' is True."""
13        # No need for instance, working directly on class level
14        return dataframe[dataframe[column_name] == True]
15
16    @classmethod
17    def filter_is_delta_false(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
18        """Filters rows where 'is_delta' is False."""
19        return dataframe[dataframe[column_name] == False]

Provides class methods for filtering is_delta columns in a pandas DataFrame.

@classmethod
def filter_is_delta_true( cls, dataframe: pandas.core.frame.DataFrame, column_name: str = 'is_delta') -> pandas.core.frame.DataFrame:
10    @classmethod
11    def filter_is_delta_true(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
12        """Filters rows where 'is_delta' is True."""
13        # No need for instance, working directly on class level
14        return dataframe[dataframe[column_name] == True]

Filters rows where 'is_delta' is True.

@classmethod
def filter_is_delta_false( cls, dataframe: pandas.core.frame.DataFrame, column_name: str = 'is_delta') -> pandas.core.frame.DataFrame:
16    @classmethod
17    def filter_is_delta_false(cls, dataframe: pd.DataFrame, column_name: str = 'is_delta') -> pd.DataFrame:
18        """Filters rows where 'is_delta' is False."""
19        return dataframe[dataframe[column_name] == False]

Filters rows where 'is_delta' is False.

Inherited Members
timeseries_shaper.base.Base
Base
dataframe
get_dataframe
class BooleanFilter(timeseries_shaper.base.Base):
22class BooleanFilter(Base):
23    """
24    Provides class methods for filtering boolean columns in a pandas DataFrame,
25    particularly focusing on status changes.
26    """
27    
28    @classmethod
29    def filter_falling_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
30        """Filters rows where 'value_bool' changes from True to False."""
31        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
32        return dataframe[(dataframe['previous_value_bool'] == True) & (dataframe[column_name] == False)]
33
34    @classmethod
35    def filter_raising_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
36        """Filters rows where 'value_bool' changes from False to True."""
37        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
38        return dataframe[(dataframe['previous_value_bool'] == False) & (dataframe[column_name] == True)]

Provides class methods for filtering boolean columns in a pandas DataFrame, particularly focusing on status changes.

@classmethod
def filter_falling_value_bool( cls, dataframe: pandas.core.frame.DataFrame, column_name: str = 'value_bool') -> pandas.core.frame.DataFrame:
28    @classmethod
29    def filter_falling_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
30        """Filters rows where 'value_bool' changes from True to False."""
31        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
32        return dataframe[(dataframe['previous_value_bool'] == True) & (dataframe[column_name] == False)]

Filters rows where 'value_bool' changes from True to False.

@classmethod
def filter_raising_value_bool( cls, dataframe: pandas.core.frame.DataFrame, column_name: str = 'value_bool') -> pandas.core.frame.DataFrame:
34    @classmethod
35    def filter_raising_value_bool(cls, dataframe: pd.DataFrame, column_name: str = 'value_bool') -> pd.DataFrame:
36        """Filters rows where 'value_bool' changes from False to True."""
37        dataframe['previous_value_bool'] = dataframe[column_name].shift(1)
38        return dataframe[(dataframe['previous_value_bool'] == False) & (dataframe[column_name] == True)]

Filters rows where 'value_bool' changes from False to True.

Inherited Members
timeseries_shaper.base.Base
Base
dataframe
get_dataframe