MissingRatio(ratio, comparison=RatioComparison.AT_LEAST)
Source¶
A ratio of missing values from which a row or a column is removed, used by MissingDrop.
The ratio of a row is its missing values divided by its number of values, and the same for a column.
Added in version 0.1.0
Parameters:
-
ratio(float)The threshold, a fraction between 0 and 1:
0.3for 30 %. -
comparison(RatioComparison, default:RatioComparison.AT_LEAST)Whether a ratio equal to the threshold is enough,
RatioComparison.AT_LEASTby default, or the ratio must be above it,RatioComparison.ABOVE.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidFractionErrorWhen
ratiois lower than 0, greater than 1 or NaN.
Examples:
import numdaplot as ndp
prices = ndp.Array.from_list([120.0, None, 80.0, None])
stocks = ndp.Array.from_list([3.0, 5.0, None, 2.0])
table = ndp.Table.from_arrays({"price": prices, "stock": stocks})
table.drop_missing(ndp.MissingDrop(rule=ndp.MissingRatio(0.4)), axis=ndp.Axis.EACH_COLUMN)
# stock
# FLOAT64
# 0 3.0
# 1 5.0
# 2 NaN
# 3 2.0