Skip to content

Commit

Permalink
Add str_cat/fullmatch/removeprefix/removesuffix
Browse files Browse the repository at this point in the history
Co-authored-by: Mahesh Vashishtha <[email protected]>
  • Loading branch information
2 people authored and vnlitvinov committed Mar 16, 2023
1 parent 5239ce1 commit 27429cc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
30 changes: 30 additions & 0 deletions modin/core/storage_formats/base/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4459,6 +4459,17 @@ def str_capitalize(self):
def str_capitalize(self):
return StrDefault.register(pandas.Series.str.capitalize)(self)

@doc_utils.doc_str_method(
refer_to="cat",
params="""
others : Series, Index, DataFrame, np.ndarray or list-like
sep : str
na_sep : str
join : {'left', 'right', 'outer', 'inner'}, default: 'left'""",
)
def str_cat(self, others=None, sep=None, na_rep=None, join="left"):
return StrDefault.register(pandas.Series.str.cat)(self, others, sep, na_rep, join)

@doc_utils.doc_str_method(
refer_to="center",
params="""
Expand Down Expand Up @@ -4523,6 +4534,17 @@ def str_findall(self, pat, flags=0, **kwargs):
self, pat, flags, **kwargs
)

@doc_utils.doc_str_method(
refer_to="fullmatch",
params="""
pat : str
case : bool, default: True
flags : int, default: 0
na : object, default: None""",
)
def str_fullmatch(self, pat, case=True, flags=0, na=None):
return StrDefault.register(pandas.Series.str.fullmatch)(self, pat, case, flags, na)

@doc_utils.doc_str_method(refer_to="get", params="i : int")
def str_get(self, i):
return StrDefault.register(pandas.Series.str.get)(self, i)
Expand Down Expand Up @@ -4644,6 +4666,14 @@ def str_pad(self, width, side="left", fillchar=" "):
def str_partition(self, sep=" ", expand=True):
return StrDefault.register(pandas.Series.str.partition)(self, sep, expand)

@doc_utils.doc_str_method(refer_to="removeprefix", params="prefix : str")
def str_removeprefix(self, prefix):
return StrDefault.register(pandas.Series.str.removeprefix)(self, prefix)

@doc_utils.doc_str_method(refer_to="removesuffix", params="suffix : str")
def str_removesuffix(self, suffix):
return StrDefault.register(pandas.Series.str.removesuffix)(self, suffix)

@doc_utils.doc_str_method(refer_to="repeat", params="repeats : int")
def str_repeat(self, repeats):
return StrDefault.register(pandas.Series.str.repeat)(self, repeats)
Expand Down
13 changes: 13 additions & 0 deletions modin/pandas/series_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ def findall(self, pat, flags=0, **kwargs):
query_compiler=self._query_compiler.str_findall(pat, flags=flags, **kwargs)
)

def fullmatch(self, pat, case=True, flags=0, na=None):
if not isinstance(pat, (str, _pattern_type)):
raise TypeError("first argument must be string or compiled pattern")
return Series(
query_compiler=self._query_compiler.str_fullmatch(pat, flags=flags, na=na)
)

def match(self, pat, case=True, flags=0, na=np.NaN):
if not isinstance(pat, (str, _pattern_type)):
raise TypeError("first argument must be string or compiled pattern")
Expand Down Expand Up @@ -334,6 +341,12 @@ def partition(self, sep=" ", expand=True):
query_compiler=self._query_compiler.str_partition(sep=sep, expand=expand)
)

def removeprefix(self, prefix):
return Series(query_compiler=self._query_compiler.str_removeprefix(prefix))

def removesuffix(self, suffix):
return Series(query_compiler=self._query_compiler.str_removesuffix(suffix))

def repeat(self, repeats):
return Series(query_compiler=self._query_compiler.str_repeat(repeats))

Expand Down

0 comments on commit 27429cc

Please sign in to comment.