-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
With floating point data, the float('NaN') special value is commonly used as a placeholder for missing values. We provide math.isnan to support stripping out those values prior to sorting or summation:
>>> from math import isnan
>>> from itertools import filterfalse
>>> data = [3.3, float('nan'), 1.1, 2.2]
>>> sorted(filterfalse(isnan, data))
[1.1, 2.2, 3.3]For non-float data, the None special value is commonly used as a placeholder for missing values. I propose a new function in the operator module analogous to math.isnan():
>>> data = ['c', None, 'a', 'b']
>>> sorted(filterfalse(is_none, data))
['a', 'b', 'c']This helps fulfill a primary use case for the operator module which is to support functional programming with map(), filter(), etc.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
AlexWaygood, ariebovenberg, erlend-aasland, Eclips4 and Gouvernathor
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement