Skip to content

Commit

Permalink
Add extended summary for fullmatch, match, pad, repeat, slice and sli…
Browse files Browse the repository at this point in the history
…ce_replace (#60520)

Add extended summary for fullmatch, match, pad, repeat, slice and slice_replace functions
  • Loading branch information
Nanashi-bot authored Dec 9, 2024
1 parent f3b7985 commit b667fdf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,11 @@ def match(self, pat: str, case: bool = True, flags: int = 0, na=lib.no_default):
"""
Determine if each string starts with a match of a regular expression.
Determines whether each string in the Series or Index starts with a
match to a specified regular expression. This function is especially
useful for validating prefixes, such as ensuring that codes, tags, or
identifiers begin with a specific pattern.
Parameters
----------
pat : str
Expand Down Expand Up @@ -1419,6 +1424,11 @@ def fullmatch(self, pat, case: bool = True, flags: int = 0, na=lib.no_default):
"""
Determine if each string entirely matches a regular expression.
Checks if each string in the Series or Index fully matches the
specified regular expression pattern. This function is useful when the
requirement is for an entire string to conform to a pattern, such as
validating formats like phone numbers or email addresses.
Parameters
----------
pat : str
Expand Down Expand Up @@ -1647,6 +1657,10 @@ def repeat(self, repeats):
"""
Duplicate each string in the Series or Index.
Duplicates each string in the Series or Index, either by applying the
same repeat count to all elements or by using different repeat values
for each element.
Parameters
----------
repeats : int or sequence of int
Expand Down Expand Up @@ -1710,6 +1724,12 @@ def pad(
"""
Pad strings in the Series/Index up to width.
This function pads strings in a Series or Index to a specified width,
filling the extra space with a character of your choice. It provides
flexibility in positioning the padding, allowing it to be added to the
left, right, or both sides. This is useful for formatting strings to
align text or ensure consistent string lengths in data processing.
Parameters
----------
width : int
Expand Down Expand Up @@ -1920,6 +1940,11 @@ def slice(self, start=None, stop=None, step=None):
"""
Slice substrings from each element in the Series or Index.
Slicing substrings from strings in a Series or Index helps extract
specific portions of data, making it easier to analyze or manipulate
text. This is useful for tasks like parsing structured text fields or
isolating parts of strings with a consistent format.
Parameters
----------
start : int, optional
Expand Down Expand Up @@ -1996,6 +2021,11 @@ def slice_replace(self, start=None, stop=None, repl=None):
"""
Replace a positional slice of a string with another value.
This function allows replacing specific parts of a string in a Series
or Index by specifying start and stop positions. It is useful for
modifying substrings in a controlled way, such as updating sections of
text based on their positions or patterns.
Parameters
----------
start : int, optional
Expand Down

0 comments on commit b667fdf

Please sign in to comment.