Skip to content

pandas.Index.slice_locs when label not found #32680

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

Open
albertotb opened this issue Mar 13, 2020 · 1 comment
Open

pandas.Index.slice_locs when label not found #32680

albertotb opened this issue Mar 13, 2020 · 1 comment
Assignees
Labels
Docs Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@albertotb
Copy link

Problem description

The documentation for pandas.Index.slice_locs does not specify what happens if the label(s) are not found. Internally it seems to be using pandas.Index.get_slice_bound, so maybe a reference to this method should be added.

Another thing that would be nice is if pandas.Index.slice_locs worked like pandas.Index.get_loc, where the method to find the index can be specified: exact, nearest, etc.

Expected Output

I would expect that the documentation for pandas.Index.slice_locs gives details about what happens if the label is not found. Details about the kind argument would also be nice.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-112-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : es_ES.UTF-8
LOCALE : es_ES.UTF-8

pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 41.4.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.15.0
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None

@jbrockmendel jbrockmendel added Indexing Related to indexing on series/frames, not to indexes themselves Docs labels Mar 13, 2020
@KeiOshima
Copy link
Contributor

take

mroeschke pushed a commit that referenced this issue Apr 3, 2024
#58135)

* add return value if non-existent label is provided in pandas.Index.slice_locs

* fix Line too long error

* remove trailing whitespace

* fix double line break

* writing as example instead of note
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this issue May 7, 2024
…s-dev#32680 (pandas-dev#58135)

* add return value if non-existent label is provided in pandas.Index.slice_locs

* fix Line too long error

* remove trailing whitespace

* fix double line break

* writing as example instead of note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

3 participants