Skip to content

Commit

Permalink
Revert " BUG: RecursionError when attempting to replace np.nan values (
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins authored and yehoshuadimarsky committed Jul 13, 2022
1 parent 9f9f0ad commit 465ab1e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 33 deletions.
1 change: 0 additions & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ def replace(
# go through replace_list

values = self.values
value = self._standardize_fill_value(value) # GH#45725

if isinstance(values, Categorical):
# TODO: avoid special-casing
Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,21 +661,6 @@ def test_replace_simple_nested_dict_with_nonexistent_value(self):
result = df.replace({"col": {-1: "-", 1: "a", 4: "b"}})
tm.assert_frame_equal(expected, result)

def test_replace_numpy_nan(self, nulls_fixture):
# GH#45725 ensure numpy.nan can be replaced with all other null types
to_replace = np.nan
value = nulls_fixture
dtype = object
df = DataFrame({"A": [to_replace]}, dtype=dtype)
expected = DataFrame({"A": [value]}, dtype=dtype)

result = df.replace({to_replace: value}).astype(dtype=dtype)
tm.assert_frame_equal(result, expected)

# same thing but different calling convention
result = df.replace(to_replace, value).astype(dtype=dtype)
tm.assert_frame_equal(result, expected)

def test_replace_value_is_none(self, datetime_frame):
orig_value = datetime_frame.iloc[0, 0]
orig2 = datetime_frame.iloc[1, 0]
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/series/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ def test_replace_explicit_none(self):
assert expected.iloc[-1] is None
tm.assert_series_equal(result, expected)

def test_replace_numpy_nan(self, nulls_fixture):
# GH#45725 ensure numpy.nan can be replaced with all other null types
to_replace = np.nan
value = nulls_fixture
dtype = object
ser = pd.Series([to_replace], dtype=dtype)
expected = pd.Series([value], dtype=dtype)

result = ser.replace({to_replace: value}).astype(dtype=dtype)
tm.assert_series_equal(result, expected)
assert result.dtype == dtype

# same thing but different calling convention
result = ser.replace(to_replace, value).astype(dtype=dtype)
tm.assert_series_equal(result, expected)
assert result.dtype == dtype

def test_replace_noop_doesnt_downcast(self):
# GH#44498
ser = pd.Series([None, None, pd.Timestamp("2021-12-16 17:31")], dtype=object)
Expand Down

0 comments on commit 465ab1e

Please sign in to comment.