xinrong-databricks commented on a change in pull request #35747:
URL: https://github.com/apache/spark/pull/35747#discussion_r821350474
##########
File path: python/pyspark/pandas/series.py
##########
@@ -4283,17 +4283,20 @@ def keys(self) -> "ps.Index":
"""
return self.index
- # TODO: 'regex', 'method' parameter
+ # TODO: introduce 'method', 'limit', 'in_place'; fully support 'regex'
def replace(
self,
to_replace: Optional[Union[Any, List, Tuple, Dict]] = None,
value: Optional[Union[List, Tuple]] = None,
- regex: bool = False,
+ regex: Union[str, bool] = False,
) -> "Series":
"""
Replace values given in to_replace with value.
Values of the Series are replaced with other values dynamically.
+ .. note:: The API supports pattern matching (and replacement) on the
whole string only,
Review comment:
```py
>>> psser = ps.Series(['bat', 'foo', 'bait', 'abc', 'bar', 'zoo'])
>>> psser.replace('ba', 'xx', regex=True)
0 xx
1 foo
2 xx
3 abc
4 xx
5 zoo
dtype: object
```
vs.
```py
>>> pser = pd.Series(['bat', 'foo', 'bait', 'abc', 'bar', 'zoo'])
>>> pser.replace('ba', 'xx', regex=True)
0 xxt
1 foo
2 xxit
3 abc
4 xxr
5 zoo
dtype: object
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]