Skip to content

Commit 0c36dc1

Browse files
author
tp
committed
Added example to MultiIndex doc string
1 parent d43aba8 commit 0c36dc1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/core/indexes/multi.py

+19
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ class MultiIndex(Index):
6868
Copy the meta-data
6969
verify_integrity : boolean, default True
7070
Check that the levels/labels are consistent and valid
71+
72+
Examples
73+
---------
74+
A new ``MultiIndex`` is typically constructed using one of the helper
75+
methods :attr:`MultiIndex.from_arrays``, :attr:`MultiIndex.from_product``
76+
and :attr:`MultiIndex.from_tuples``. For example (using ``.from_arrays``):
77+
78+
>>> arrays = [[1, 1, 2, 2], ['red', 'blue', 'red', 'blue']]
79+
>>> MultiIndex.from_arrays(arrays, names=('number', 'color'))
80+
81+
See further examples for how to construct a MultiIndex in the doc strings
82+
of the mentioned helper methods.
83+
84+
See also
85+
--------
86+
MultiIndex.from_arrays : Convert list of arrays to MultiIndex
87+
MultiIndex.from_product : Create a MultiIndex from the cartesian product
88+
of iterables
89+
MultiIndex.from_tuples : Convert list of tuples to a MultiIndex
7190
"""
7291

7392
# initialize to zero-length tuples to make everything work

0 commit comments

Comments
 (0)