diff --git a/nnfwtbn/cut.py b/nnfwtbn/cut.py index 0a410f0e103a50fa3ba7e78e14a9bceb68c65a17..74227e4a6464fa7ad16422b45326c825c7467044 100644 --- a/nnfwtbn/cut.py +++ b/nnfwtbn/cut.py @@ -14,18 +14,27 @@ class Cut: >>> sel_all = Cut() >>> sel_pos = Cut(lambda df: df.value > 0) - The cut object lives independently of the dataframe. The index array for a - given data set is calculated by calling the cut with data dataframe. + The cut object lives independently of the dataframe. Calling the cut with + a dataframe returns a new dataframe containing only rows which pass the + selection criteria. >>> df = pd.DataFrame([0, 1, -2, -3, 4], columns=["value"]) >>> sel_all(df) - 0 True - 1 True - 2 True - 3 True - 4 True - dtype: bool + value + 0 0 + 1 1 + 2 -2 + 3 -3 + 4 4 >>> sel_pos(df) + value + 1 1 + 4 4 + + The index array for a given data set is calculated by calling the + idx_array() method with a data dataframe. + + >>> sel_pos.idx_array(df) 0 False 1 True 2 False @@ -39,23 +48,15 @@ class Cut: >>> sel_even = Cut(lambda df: df.value % 2 == 0) >>> sel_pos_even = sel_pos & sel_even >>> sel_pos_even(df) - 0 False - 1 False - 2 False - 3 False - 4 True - Name: value, dtype: bool + value + 4 4 Equivalently, cuts support logical operations directly using lambdas. >>> sel_pos_even_lambda = sel_pos & (lambda df: df.value % 2 == 0) >>> sel_pos_even_lambda(df) - 0 False - 1 False - 2 False - 3 False - 4 True - Name: value, dtype: bool + value + 4 4 """ def __init__(self, func=None):