MulSeries.nloc#
- MulSeries.nloc#
Flexible hierachical indexing on the index dataframe using positions.
The slicer can be a list or a dict. Check introduction to mloc ??? for detailed usage.
If a list is used, it behaves exactly like MulSeries.mloc.
If a dict is used, it behaves similarly to MulSeries.mloc except that instead of using column names as keys, it uses the numeric positions of the columns as keys.
Examples#
Dictionary indexing:
>>> import pandas as pd >>> import muldataframe as md >>> index = pd.DataFrame([['a','b','c'], [ 'g','b','f'], [ 'b','g','h']], columns=['x','y','y']) >>> name = pd.Series(['a','b'],index=['e','f'],name='cc') >>> ms = md.MulSeries([1,2,3],index=index,name=name) >>> ms.nloc[{1:['b','g'],0:['b','a']}] (2,) e a f b cc ---------- ------ x y y cc 2 b g h 2 3 0 a b c 0 1
Note that with a dict in MulSeries.mloc, you can only select the last
ycolumn in the index dataframe. Usingnlocyou are able to select the firstycolumn.
MulDataFrame