Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.str.removeprefix#

Series.str.removeprefix(prefix)[source]#

Remove a prefix from an object series.

If the prefix is not present, the original string will be returned.

Parameters:
prefixstr

Remove the prefix of the string.

Returns:
Series/Index: object

The Series or Index with given prefix removed.

See also

Series.str.removesuffix

Remove a suffix from an object series.

Examples

>>>s=pd.Series(["str_foo","str_bar","no_prefix"])>>>s0    str_foo1    str_bar2    no_prefixdtype: object>>>s.str.removeprefix("str_")0    foo1    bar2    no_prefixdtype: object
>>>s=pd.Series(["foo_str","bar_str","no_suffix"])>>>s0    foo_str1    bar_str2    no_suffixdtype: object>>>s.str.removesuffix("_str")0    foo1    bar2    no_suffixdtype: object

[8]ページ先頭

©2009-2025 Movatter.jp