A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/../api/pandas.Series.str.slice.html below:

pandas.Series.str.slice — pandas 2.3.1 documentation

pandas.Series.str.slice#
Series.str.slice(start=None, stop=None, step=None)[source]#

Slice substrings from each element in the Series or Index.

Parameters:
startint, optional

Start position for slice operation.

stopint, optional

Stop position for slice operation.

stepint, optional

Step size for slice operation.

Returns:
Series or Index of object

Series or Index from sliced substring from original string object.

Examples

>>> s = pd.Series(["koala", "dog", "chameleon"])
>>> s
0        koala
1          dog
2    chameleon
dtype: object
>>> s.str.slice(start=1)
0        oala
1          og
2    hameleon
dtype: object
>>> s.str.slice(start=-1)
0           a
1           g
2           n
dtype: object
>>> s.str.slice(stop=2)
0    ko
1    do
2    ch
dtype: object
>>> s.str.slice(step=2)
0      kaa
1       dg
2    caeen
dtype: object
>>> s.str.slice(start=0, stop=5, step=3)
0    kl
1     d
2    cm
dtype: object

Equivalent behaviour to:

>>> s.str[0:5:3]
0    kl
1     d
2    cm
dtype: object

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4