pandas 1.4.2

ParametersReturnsBackRef
slice(self, start=None, stop=None, step=None)

Parameters

start : int, optional

Start position for slice operation.

stop : int, optional

Stop position for slice operation.

step : int, optional

Step size for slice operation.

Returns

Series or Index of object

Series or Index from sliced substring from original string object.

Slice substrings from each element in the Series or Index.

See Also

Series.str.get

Return element at position. Equivalent to :None:None:`Series.str.slice(start=i, stop=i+1)` with :None:None:`i` being the position.

Series.str.slice_replace

Replace a slice with a string.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(["koala", "dog", "chameleon"])
... s 0 koala 1 dog 2 chameleon dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.slice(start=1)
0        oala
1          og
2    hameleon
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.slice(start=-1)
0           a
1           g
2           n
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.slice(stop=2)
0    ko
1    do
2    ch
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.slice(step=2)
0      kaa
1       dg
2    caeen
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.slice(start=0, stop=5, step=3)
0    kl
1     d
2    cm
dtype: object

Equivalent behaviour to:

This example is valid syntax, but we were not able to check execution
>>> s.str[0:5:3]
0    kl
1     d
2    cm
dtype: object
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.indexing._iLocIndexer

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/strings/accessor.py#1678
type: <class 'function'>
Commit: