Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into issue-30512
  • Loading branch information
MarcoGorelli committed Jun 13, 2020
commit 5e143fbc4bc55ad74798752889ceb428501b3abb
Binary file added kite-installer
Binary file not shown.
23 changes: 23 additions & 0 deletions pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,29 @@ def test_replace_tz_aware_dont_change_other_columns(self, tz_aware_fixture):
value_b = Timestamp("20130103", tz=tz_aware_fixture)
_test_replace_doesnt_change_other_columns(value_a, value_b, None)

@pytest.mark.parametrize("dtype", ["float", "float64", "int64", "Int64", "boolean"])
@pytest.mark.parametrize("value", [np.nan, pd.NA])
def test_replace_no_replacement_dtypes(self, dtype, value):
# https://github.com/pandas-dev/pandas/issues/32988
df = pd.DataFrame(np.eye(2), dtype=dtype)
result = df.replace(to_replace=[None, -np.inf, np.inf], value=value)
tm.assert_frame_equal(result, df)

@pytest.mark.parametrize("replacement", [np.nan, 5])
def test_replace_with_duplicate_columns(self, replacement):
# GH 24798
result = pd.DataFrame({"A": [1, 2, 3], "A1": [4, 5, 6], "B": [7, 8, 9]})
result.columns = list("AAB")

expected = pd.DataFrame(
{"A": [1, 2, 3], "A1": [4, 5, 6], "B": [replacement, 8, 9]}
)
expected.columns = list("AAB")

result["B"] = result["B"].replace(7, replacement)

tm.assert_frame_equal(result, expected)


def _test_replace_doesnt_change_other_columns(value_a, value_b, dtype):
# GH30512
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.