-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: inconsistency in dtype of replace() #44897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d0565b1
2fc7c96
cb4dd4f
1129c9a
1a1c378
eb06d43
fdbd5f5
087aad2
d0f3c7f
54f5676
c83c2b6
a438762
9617165
36e9a5d
f04d05d
ddbb113
75e3bd8
af0585c
2a80b69
e281264
d00915b
2fd474c
0d93bdd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -512,3 +512,10 @@ def test_pandas_replace_na(self): | |
result = ser.replace(regex_mapping, regex=True) | ||
exp = pd.Series(["CC", "CC", "CC-REPL", "DD", "CC", "", pd.NA], dtype="string") | ||
tm.assert_series_equal(result, exp) | ||
|
||
def test_replace_regex_dtype(self): | ||
# GH-48644 | ||
s = pd.Series(["0"]) | ||
exp = s.replace(to_replace="0", value=1, regex=False).dtype | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. explictly create the expected and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you should create expected = Series(...) not using replace. And please don't use one letter variable names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
res = s.replace(to_replace="0", value=1, regex=True).dtype | ||
assert exp == res |
Uh oh!
There was an error while loading. Please reload this page.