nimble.fill.mode

nimble.fill.mode(vector, match)

Fill matched values with the mode.

The calculation of the mode will ignore any matched values. If all the values are a match the mean cannot be calculated.

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 mode replacing the match values.

See also

mean, median, nimble.match

Examples

Match a value.

>>> lst = [1, 'na', 1, 'na', 5]
>>> X = nimble.data(lst)
>>> mode(X, 'na')
<DataFrame 1pt x 5ft
     0  1  2  3  4
   ┌──────────────
 0 │ 1  1  1  1  5
>

Match using a function from nimble’s match module.

>>> from nimble import match
>>> lst = [6, 6, 2, 0, 0]
>>> X = nimble.data(lst)
>>> mode(X, match.zero)
<Matrix 1pt x 5ft
     0  1  2  3  4
   ┌──────────────
 0 │ 6  6  2  6  6
>