nimble.fill.median¶
- nimble.fill.median(vector, match)¶
Fill matched values with the median.
The calculation of the median will ignore any matched values, but all unmatched values must be numeric. If all the values are a match the median 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 median replacing the
match
values.
See also
Examples
Match a value.
>>> lst = [1, 'na', 3, 'na', 5] >>> X = nimble.data(lst) >>> median(X, 'na') <DataFrame 1pt x 5ft 0 1 2 3 4 ┌────────────────────── 0 │ 1 3.000 3 3.000 5 >
Match using a function from nimble’s match module.
>>> from nimble import match >>> lst = [6, 0, 2, 0, 4] >>> X = nimble.data(lst) >>> median(X, match.zero) <Matrix 1pt x 5ft 0 1 2 3 4 ┌────────────────────────────────── 0 │ 6.000 4.000 2.000 4.000 4.000 >