Skip to content

DOC: Series.str.slice() should show that negative values for start are allowed #27802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dr-Irv opened this issue Aug 7, 2019 · 0 comments · Fixed by #27832
Closed

DOC: Series.str.slice() should show that negative values for start are allowed #27802

Dr-Irv opened this issue Aug 7, 2019 · 0 comments · Fixed by #27832

Comments

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Aug 7, 2019

Code Sample, a copy-pastable example if possible

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '0.25.0'

In [3]: s = pd.Series(["A1", "BC2", "DEF3"])

In [4]: s
Out[4]:
0      A1
1     BC2
2    DEF3
dtype: object

In [5]: s.str.slice(start=-1)
Out[5]:
0    1
1    2
2    3
dtype: object

In [6]: s.str[:-1]
Out[6]:
0      A
1     BC
2    DEF
dtype: object

Problem description

It is not apparent from the documentation at https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.slice.html that you can specify negative values for the start and stop arguments. So I think this should be stated, as well as used in some examples (as shown above).

Expected Output

N/A

Output of pd.show_versions()

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants