Skip to content

BUG: step argument in the slice StringMethod not working #8754

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

The step argument in the slice StringMethods has no effect:

In [18]: s = pd.Series(['abcde', 'fghij'])

In [19]: s.str.slice?
Definition:  s.str.slice(self, start=None, stop=None, step=1)
Slice substrings from each element in array

Parameters
----------
start : int or None
stop : int or None

Returns
-------
sliced : array

In [22]: s.str.slice(step=1)
Out[22]: 
0    abcde
1    fghij
dtype: object

In [23]: s.str.slice(step=2)
Out[23]: 
0    abcde
1    fghij
dtype: object

In [24]: s[0][::2]
Out[24]: 'ace'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions