Skip to content

Commit b422aab

Browse files
authored
CLN: remove no-longer-used ignore_failures in frame_apply (#37851)
1 parent 7e96ad6 commit b422aab

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

pandas/core/apply.py

+7-26
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def frame_apply(
2626
axis: Axis = 0,
2727
raw: bool = False,
2828
result_type: Optional[str] = None,
29-
ignore_failures: bool = False,
3029
args=None,
3130
kwds=None,
3231
):
@@ -43,7 +42,6 @@ def frame_apply(
4342
func,
4443
raw=raw,
4544
result_type=result_type,
46-
ignore_failures=ignore_failures,
4745
args=args,
4846
kwds=kwds,
4947
)
@@ -84,13 +82,11 @@ def __init__(
8482
func,
8583
raw: bool,
8684
result_type: Optional[str],
87-
ignore_failures: bool,
8885
args,
8986
kwds,
9087
):
9188
self.obj = obj
9289
self.raw = raw
93-
self.ignore_failures = ignore_failures
9490
self.args = args or ()
9591
self.kwds = kwds or {}
9692

@@ -283,29 +279,14 @@ def apply_series_generator(self) -> Tuple[ResType, "Index"]:
283279

284280
results = {}
285281

286-
if self.ignore_failures:
287-
successes = []
282+
with option_context("mode.chained_assignment", None):
288283
for i, v in enumerate(series_gen):
289-
try:
290-
results[i] = self.f(v)
291-
except Exception:
292-
pass
293-
else:
294-
successes.append(i)
295-
296-
# so will work with MultiIndex
297-
if len(successes) < len(res_index):
298-
res_index = res_index.take(successes)
299-
300-
else:
301-
with option_context("mode.chained_assignment", None):
302-
for i, v in enumerate(series_gen):
303-
# ignore SettingWithCopy here in case the user mutates
304-
results[i] = self.f(v)
305-
if isinstance(results[i], ABCSeries):
306-
# If we have a view on v, we need to make a copy because
307-
# series_generator will swap out the underlying data
308-
results[i] = results[i].copy(deep=False)
284+
# ignore SettingWithCopy here in case the user mutates
285+
results[i] = self.f(v)
286+
if isinstance(results[i], ABCSeries):
287+
# If we have a view on v, we need to make a copy because
288+
# series_generator will swap out the underlying data
289+
results[i] = results[i].copy(deep=False)
309290

310291
return results, res_index
311292

pandas/tests/frame/apply/test_frame_apply.py

-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import pandas as pd
1111
from pandas import DataFrame, MultiIndex, Series, Timestamp, date_range, notna
1212
import pandas._testing as tm
13-
from pandas.core.apply import frame_apply
1413
from pandas.core.base import SpecificationError
1514
from pandas.tests.frame.common import zip_frames
1615

@@ -267,13 +266,6 @@ def test_apply_axis1(self, float_frame):
267266
tapplied = float_frame.apply(np.mean, axis=1)
268267
assert tapplied[d] == np.mean(float_frame.xs(d))
269268

270-
def test_apply_ignore_failures(self, float_string_frame):
271-
result = frame_apply(
272-
float_string_frame, np.mean, 0, ignore_failures=True
273-
).apply_standard()
274-
expected = float_string_frame._get_numeric_data().apply(np.mean)
275-
tm.assert_series_equal(result, expected)
276-
277269
def test_apply_mixed_dtype_corner(self):
278270
df = DataFrame({"A": ["foo"], "B": [1.0]})
279271
result = df[:0].apply(np.mean, axis=1)

0 commit comments

Comments
 (0)