-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Multiindex slicing df.loc[idx[dim1,dim2,dim3],:] not working right in some cases #12896
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
I believe |
hmm, something funny going on. This gives something odd as well.
|
Any idea what this could be? It seems to be related to the size of the index - how could that be? Correct with an index of 1500: In [240]: l=1500
In [241]: ints = (pd.np.random.rand(l)*1e6).round().astype('int')
In [242]: index=pd.MultiIndex.from_arrays([list('abc')*(l//3), ints])
In [243]: series=pd.Series(np.random.rand(l), index=index)
In [244]: series.sort_index().loc[(slice(None), slice(1e5))]
Out[244]:
a 2360 0.501724
5253 0.892526
10122 0.158961
15737 0.927828
...
94452 0.460249
96376 0.248980
97572 0.514986
99746 0.719964
dtype: float64 Incorrect with an index of 15000: In [245]: l=15000
In [246]: ints = (pd.np.random.rand(l)*1e6).round().astype('int')
In [247]: index=pd.MultiIndex.from_arrays([list('abc')*(l//3), ints])
In [248]: series=pd.Series(np.random.rand(l), index=index)
In [249]: series.sort_index().loc[(slice(None), slice(1e5))]
Out[249]:
a 409 0.317578
582 0.526421
584 0.620082
838 0.139467
...
859804 0.510514
947555 0.951258
dtype: float64 |
Yup. But there mus be somewhere where the behavior is different depending on the size of the index? |
sounds interesting. I'll give this a go |
Looks solved, thanks for the effort everyone! I guess you will close this upon merge, or I will once it's through. Cheers! |
Code Sample, a copy-pastable example if possible
Output
output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 3.16.0-59-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.2.2
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.3
sphinx: 1.3.5
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.6
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
The text was updated successfully, but these errors were encountered: