Predicates (datascience.predicates
)¶
Predicate functions.
- class datascience.predicates.are[source]¶
Predicate functions. The class is named “are” for calls to where.
For example, given a table, predicates can be used to pick rows as follows.
>>> from datascience import Table >>> t = Table().with_columns([ ... 'Sizes', ['S', 'M', 'L', 'XL'], ... 'Waists', [30, 34, 38, 42], ... ]) >>> t.where('Sizes', are.equal_to('L')) Sizes | Waists L | 38 >>> t.where('Waists', are.above(38)) Sizes | Waists XL | 42 >>> t.where('Waists', are.above_or_equal_to(38)) Sizes | Waists L | 38 XL | 42 >>> t.where('Waists', are.below(38)) Sizes | Waists S | 30 M | 34 >>> t.where('Waists', are.below_or_equal_to(38)) Sizes | Waists S | 30 M | 34 L | 38 >>> t.where('Waists', are.strictly_between(30, 38)) Sizes | Waists M | 34 >>> t.where('Waists', are.between(30, 38)) Sizes | Waists S | 30 M | 34 >>> t.where('Waists', are.between_or_equal_to(30, 38)) Sizes | Waists S | 30 M | 34 L | 38 >>> t.where('Sizes', are.equal_to('L')) Sizes | Waists L | 38 >>> t.where('Waists', are.not_above(38)) Sizes | Waists S | 30 M | 34 L | 38 >>> t.where('Waists', are.not_above_or_equal_to(38)) Sizes | Waists S | 30 M | 34 >>> t.where('Waists', are.not_below(38)) Sizes | Waists L | 38 XL | 42 >>> t.where('Waists', are.not_below_or_equal_to(38)) Sizes | Waists XL | 42 >>> t.where('Waists', are.not_strictly_between(30, 38)) Sizes | Waists S | 30 L | 38 XL | 42 >>> t.where('Waists', are.not_between(30, 38)) Sizes | Waists L | 38 XL | 42 >>> t.where('Waists', are.not_between_or_equal_to(30, 38)) Sizes | Waists XL | 42 >>> t.where('Sizes', are.containing('L')) Sizes | Waists L | 38 XL | 42 >>> t.where('Sizes', are.not_containing('L')) Sizes | Waists S | 30 M | 34 >>> t.where('Sizes', are.contained_in('MXL')) Sizes | Waists M | 34 L | 38 XL | 42 >>> t.where('Sizes', are.contained_in('L')) Sizes | Waists L | 38 >>> t.where('Sizes', are.not_contained_in('MXL')) Sizes | Waists S | 30