-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
str.replace('.','') should replace every character? (fix) #24809
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 2 commits
c984582
67b0870
340ae89
5a4e131
cf8dc79
924ecc8
97bf73a
da16172
93a0715
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 |
---|---|---|
|
@@ -1008,6 +1008,13 @@ def test_replace(self): | |
values = klass(data) | ||
pytest.raises(TypeError, values.str.replace, 'a', repl) | ||
|
||
def test_replace_single_pattern(self): | ||
values = Series(['abc','123']) | ||
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. Can you add a comment for the issue ( 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. Yes |
||
|
||
result = values.str.replace('.', 'foo') | ||
exp = Series(['foofoofoo', 'foofoofoo']) | ||
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. Can you name this 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. Sure, should I make another PR? 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 just add as a commit and push on the same branch. Looks like CI failed too -haven’t checked but make sure tests pass locally before pushing 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. Yes, i've seem that.
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. What to think about that? |
||
tm.assert_series_equal(result, exp) | ||
|
||
def test_replace_callable(self): | ||
# GH 15055 | ||
values = Series(['fooBAD__barBAD', NA]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need the
len(pat)
condition? Can it just bepat
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be just
pat
, the only issue is casepat
is empty.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn’t that be False in either case? If so shouldn’t need the len expression