nimble.fill.forwardFill¶
- nimble.fill.forwardFill(vector, match)¶
Fill matched values with the previous unmatched value.
Each matching value will be filled with the first non-matching value occurring prior to the matched value. An exception will be raised if the first 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 forward filled values replacing the
match
values.
See also
Examples
Match a value.
>>> lst = [1, 'na', 3, 'na', 5] >>> X = nimble.data(lst) >>> forwardFill(X, 'na') <DataFrame 1pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 1 1 3 3 5 >
Match using a function from nimble’s match module.
>>> from nimble import match >>> lst = [6, 0, 2, 0, 4] >>> X = nimble.data(lst) >>> forwardFill(X, match.zero) <Matrix 1pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 6 6 2 2 4 >