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
static above(y)[source]

Greater than y.

static above_or_equal_to(y)[source]

Greater than or equal to y.

static below(y)[source]

Less than y.

static below_or_equal_to(y)[source]

Less than or equal to y.

static between(y, z)[source]

Greater than or equal to y and less than z.

static between_or_equal_to(y, z)[source]

Greater than or equal to y and less than or equal to z.

static contained_in(superstring)[source]

A string that is part of the given superstring.

static containing(substring)[source]

A string that contains within it the given substring.

static equal_to(y)[source]

Equal to y.

static not_above(y)[source]

Is not above y

static not_above_or_equal_to(y)[source]

Is neither above y nor equal to y

static not_below(y)[source]

Is not below y

static not_below_or_equal_to(y)[source]

Is neither below y nor equal to y

static not_between(y, z)[source]

Is equal to y or less than y or greater than z

static not_between_or_equal_to(y, z)[source]

Is less than y or greater than z

static not_contained_in(superstring)[source]

A string that is not contained within the superstring

static not_containing(substring)[source]

A string that does not contain substring

static not_equal_to(y)[source]

Is not equal to y

static not_strictly_between(y, z)[source]

Is equal to y or equal to z or less than y or greater than z

static strictly_between(y, z)[source]

Greater than y and less than z.