-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Wrong slicing behavior for DataFrame loc #14900
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
Comments
http://pandas.pydata.org/pandas-docs/stable/indexing.html#selection-by-label label slicing always includes the endpoint positional (iloc) slicing matches python semantics |
Isn't the example below producing empty slice ?
|
read the docs |
What would we loose by being consistent? Performance over consistent behavior is not even a contest. |
you are missing the point .iloc is positional indexing these are two separate and distinct ways of selecting data pandas can also index by labels; since these can be for example strings (or datetimes or integers) again the docs are very complete on these concepts and if you chose not to use label indexing, then just use .iloc and it will feel like python/numpy |
Code Sample, a copy-pastable example if possible
For loc, slicing is incorrect
The behavior exhibited by slicing of loc is incosistent with python array slicing.
For [0:0] it should have returned empty, but it is returning a row.
Expected Output
Similar to code show below for python array, pd.DataFrame.loc slicing should produce empty
E.g. Following code slices empty for [0:0]
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.1.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.19.1
nose: None
pip: 9.0.1
setuptools: 25.2.0
Cython: None
numpy: 1.10.4
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: 2.2.0-b1
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: