Series.str.
slice
Slice substrings from each element in the Series or Index.
start (int, optional) – Start position for slice operation.
stop (int, optional) – Stop position for slice operation.
step (int, optional) – Step size for slice operation.
Series or Index from sliced substring from original string object.
Series or Index of object
参见
Series.str.slice_replace
Replace a slice with a string.
Series.str.get
Return element at position. Equivalent to Series.str.slice(start=i, stop=i+1) with i being the position.
实际案例
>>> import mars.dataframe as md >>> s = md.Series(["koala", "fox", "chameleon"]) >>> s.execute() 0 koala 1 fox 2 chameleon dtype: object
>>> s.str.slice(start=1).execute() 0 oala 1 ox 2 hameleon dtype: object
>>> s.str.slice(start=-1).execute() 0 a 1 x 2 n dtype: object
>>> s.str.slice(stop=2).execute() 0 ko 1 fo 2 ch dtype: object
>>> s.str.slice(step=2).execute() 0 kaa 1 fx 2 caeen dtype: object
>>> s.str.slice(start=0, stop=5, step=3).execute() 0 kl 1 f 2 cm dtype: object
Equivalent behaviour to:
>>> s.str[0:5:3].execute() 0 kl 1 f 2 cm dtype: object