nimble.fill.constant¶
- nimble.fill.constant(vector, match, constantValue)¶
Fill matched values with a constant value.
- Parameters:
vector (nimble point or feature) – A nimble Base object containing one point or feature.
match (value or function) –
value - The value which should be filled if it occurs in the data.
function - Input a value and return True if that value should be filled. Nimble offers common use-case functions in its match module.
constantValue (value) – The value which will replace any matching values.
- Returns:
list – The vector values with the
constantValue
replacing thematch
values.
See also
Examples
Match a value.
>>> lst = [1, 'na', 3, 'na', 5] >>> X = nimble.data(lst) >>> constant(X, 'na', 0) <DataFrame 1pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 1 0 3 0 5 >
Match using a function from nimble’s match module.
>>> from nimble import match >>> lst = [1, 0, 3, 0, 5] >>> X = nimble.data(lst) >>> constant(X, match.zero, 99) <Matrix 1pt x 5ft 0 1 2 3 4 ┌──────────────── 0 │ 1 99 3 99 5 >