Skip to content

REF: BlockManager.apply_allow_failures #34714

Closed
@jbrockmendel

Description

@jbrockmendel

cc @mroeschke w/r/t rolling ._apply, @WillAyd w/r/t _cython_agg_blocks, and anyone else w/r/t DataFrame._reducewith numeric_only=None, apply.FrameApply with ignore_failures=True.

All of these do something along the lines of:

results = []
exclude = []
for i, block in enumerate(mgr.blocks):
    try:
          res = func(block.values)
          results.append(res)
    except:
          exclude.append(i)

out = reconstruct(results, exclude)

Two things should be done with this pattern:

  1. Deprecate it, since it is a disproportionate maintainence burden
  2. implement something like BlockManager.apply_with_ignore_failures that would resemble BlockManager.apply but with the try/except logic*

* We could add that logic into BlockManager.apply, but BM.apply assumes the output has the same shape as the original frame, which I don't think holds for the cases mentioned above, so that would be a little more invasive than just adding a try/except.

Metadata

Metadata

Assignees

No one assigned

    Labels

    InternalsRelated to non-user accessible pandas implementationRefactorInternal refactoring of code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions