Skip to content
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

Add extended summary for fullmatch, match, pad, repeat, slice and slice_replace #60520

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading