@@ -345,7 +345,7 @@ can think of MultiIndex an array of tuples where each tuple is unique. A
345
345
346
346
.. ipython :: python
347
347
348
- arrays = [[' bar' , ' bar' , ' baz' , ' baz' , ' qux ' , ' qux ' , ' foo ' , ' foo ' ],
348
+ arrays = [[' bar' , ' bar' , ' baz' , ' baz' , ' foo ' , ' foo ' , ' qux ' , ' qux ' ],
349
349
[' one' , ' two' , ' one' , ' two' , ' one' , ' two' , ' one' , ' two' ]]
350
350
tuples = zip (* arrays)
351
351
tuples
@@ -362,18 +362,47 @@ of the index is up to you:
362
362
df
363
363
DataFrame(randn(6 , 6 ), index = index[:6 ], columns = index[:6 ])
364
364
365
+ We've "sparsified" the higher levels of the indexes to make the console output a
366
+ bit easier on the eyes.
367
+
368
+ It's worth keeping in mind that there's nothing preventing you from using tuples
369
+ as atomic labels on an axis:
370
+
371
+ .. ipython :: python
372
+
373
+ Series(randn(8 ), index = tuples)
374
+
375
+ The reason that the MultiIndex matters is that it can allow you to do grouping,
376
+ selection, and reshaping operations as we will describe below and in subsequent
377
+ areas of the documentation.
378
+
365
379
Basic indexing on axis with MultiIndex
366
380
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367
381
382
+ One of the important features of hierarchical indexing is that you can select
383
+ data by a "partial" label identifying a subgroup in the data. **Partial **
384
+ selection "drops" levels of the hierarchical index in the result in a completely
385
+ analogous way to selecting a column in a regular DataFrame:
386
+
368
387
.. ipython :: python
369
388
370
389
df[' bar' ]
390
+ df[' bar' , ' one' ]
391
+ df[' bar' ][' one' ]
392
+ s[' qux' ]
371
393
372
394
Advanced indexing with hierarchical index
373
395
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374
396
375
- Interaction with ``reindex ``
376
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397
+ Data alignment and ``reindex ``
398
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399
+
400
+
401
+
402
+ "Sortedness" issues
403
+ ~~~~~~~~~~~~~~~~~~~
404
+
405
+
377
406
378
407
Indexing internal details
379
408
-------------------------
0 commit comments