diff --git a/pandas/core/apply.py b/pandas/core/apply.py index fa4fbe711fbe4..c5260deafc0c3 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -26,7 +26,6 @@ def frame_apply( axis: Axis = 0, raw: bool = False, result_type: Optional[str] = None, - ignore_failures: bool = False, args=None, kwds=None, ): @@ -43,7 +42,6 @@ def frame_apply( func, raw=raw, result_type=result_type, - ignore_failures=ignore_failures, args=args, kwds=kwds, ) @@ -84,13 +82,11 @@ def __init__( func, raw: bool, result_type: Optional[str], - ignore_failures: bool, args, kwds, ): self.obj = obj self.raw = raw - self.ignore_failures = ignore_failures self.args = args or () self.kwds = kwds or {} @@ -283,29 +279,14 @@ def apply_series_generator(self) -> Tuple[ResType, "Index"]: results = {} - if self.ignore_failures: - successes = [] + with option_context("mode.chained_assignment", None): for i, v in enumerate(series_gen): - try: - results[i] = self.f(v) - except Exception: - pass - else: - successes.append(i) - - # so will work with MultiIndex - if len(successes) < len(res_index): - res_index = res_index.take(successes) - - else: - with option_context("mode.chained_assignment", None): - for i, v in enumerate(series_gen): - # ignore SettingWithCopy here in case the user mutates - results[i] = self.f(v) - if isinstance(results[i], ABCSeries): - # If we have a view on v, we need to make a copy because - # series_generator will swap out the underlying data - results[i] = results[i].copy(deep=False) + # ignore SettingWithCopy here in case the user mutates + results[i] = self.f(v) + if isinstance(results[i], ABCSeries): + # If we have a view on v, we need to make a copy because + # series_generator will swap out the underlying data + results[i] = results[i].copy(deep=False) return results, res_index diff --git a/pandas/tests/frame/apply/test_frame_apply.py b/pandas/tests/frame/apply/test_frame_apply.py index 162035b53d68d..f080d4b8bcc36 100644 --- a/pandas/tests/frame/apply/test_frame_apply.py +++ b/pandas/tests/frame/apply/test_frame_apply.py @@ -10,7 +10,6 @@ import pandas as pd from pandas import DataFrame, MultiIndex, Series, Timestamp, date_range, notna import pandas._testing as tm -from pandas.core.apply import frame_apply from pandas.core.base import SpecificationError from pandas.tests.frame.common import zip_frames @@ -267,13 +266,6 @@ def test_apply_axis1(self, float_frame): tapplied = float_frame.apply(np.mean, axis=1) assert tapplied[d] == np.mean(float_frame.xs(d)) - def test_apply_ignore_failures(self, float_string_frame): - result = frame_apply( - float_string_frame, np.mean, 0, ignore_failures=True - ).apply_standard() - expected = float_string_frame._get_numeric_data().apply(np.mean) - tm.assert_series_equal(result, expected) - def test_apply_mixed_dtype_corner(self): df = DataFrame({"A": ["foo"], "B": [1.0]}) result = df[:0].apply(np.mean, axis=1)