Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add operator.is_none() #115808

Closed
Closed
Labels
type-featureA feature request or enhancement
@rhettinger

Description

@rhettinger

Feature or enhancement

Proposal:

With floating point data, thefloat('NaN') special value is commonly used as a placeholder for missing values. We providemath.isnan to support stripping out those values prior to sorting or summation:

>>>frommathimportisnan>>>fromitertoolsimportfilterfalse>>>data= [3.3,float('nan'),1.1,2.2]>>>sorted(filterfalse(isnan,data))[1.1,2.2,3.3]

For non-float data, theNone special value is commonly used as a placeholder for missing values. I propose a new function in the operator module analogous tomath.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 withmap(),filter(), etc.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp