nimble.fill.backwardFill¶
- nimble.fill.backwardFill(vector, match)¶
Fill matched values with the next unmatched value.
Each matching value will be filled with the first non-matching value occurring after to the matched value. An exception will be raised if the last value is a match, since there is not a valid value to reference.
- 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.
- Returns:
list – The vector values with the backward filled values replacing the
match
values.
See also
Examples
Match a value.
>>> lst = [1, 'na', 3, 'na', 5] >>> X = nimble.data(lst) >>> backwardFill(X, 'na') <DataFrame 1pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 1 3 3 5 5 >
Match using a function from nimble’s match module.
>>> from nimble import match >>> lst = [6, 0, 2, 0, 4] >>> X = nimble.data(lst) >>> backwardFill(X, match.zero) <Matrix 1pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 6 2 2 4 4 >