Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork18.5k
Closed
Description
In [42]:fromitertoolsimportproductIn [43]:importpandasaspdIn [44]:importnumpyasnpIn [45]:index=pd.MultiIndex.from_tuples([tfortinproduct([10,20,30], ['a','b'])])In [46]:df=pd.DataFrame(np.random.randn(6,6),index,index)In [47]:dfOut[47]:102030ababab10a0.0773680.3600180.649403-0.221877-1.5274110.485647b0.890805-2.1422970.758411-1.6507100.041276-0.04089420a-0.4016780.481390-1.0807350.6218611.410940-1.106015b-0.504422-1.555415-0.0238590.211287-0.3216430.14089530a-0.118969-0.432082-0.8887861.167191-1.642356-0.281661b-0.5801822.920769-0.6856171.3277840.691514-0.692361
Slicing ranges is consistent between both axis.
In [48]:df.ix[10:20, :]Out[48]:102030ababab10a0.0773680.3600180.649403-0.221877-1.5274110.485647b0.890805-2.1422970.758411-1.6507100.041276-0.04089420a-0.4016780.481390-1.0807350.6218611.410940-1.106015b-0.504422-1.555415-0.0238590.211287-0.3216430.140895In [49]:df.ix[:,10:20]Out[49]:1020abab10a0.0773680.3600180.649403-0.221877b0.890805-2.1422970.758411-1.65071020a-0.4016780.481390-1.0807350.621861b-0.504422-1.555415-0.0238590.21128730a-0.118969-0.432082-0.8887861.167191b-0.5801822.920769-0.6856171.327784
This is inconsistent to me:
In [50]:df.ix[10, :]Out[50]:102030abababa0.0773680.3600180.649403-0.221877-1.5274110.485647b0.890805-2.1422970.758411-1.6507100.041276-0.040894In [51]:df.ix[:,10]---------------------------------------------------------------------------IndexErrorTraceback (mostrecentcalllast)...IndexError:indexoutofbounds
and this also
In [52]:df.ix[0, :]---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)...KeyError:0In [53]:df.ix[:,0]Out[53]:10a0.077368b0.89080520a-0.401678b-0.50442230a-0.118969b-0.580182Name: (10,a),Dtype:float64