@@ -739,18 +739,6 @@ def set_levels(self, levels, level=None, inplace=False, verify_integrity=True):
739
739
"""
740
740
Set new levels on MultiIndex. Defaults to returning new index.
741
741
742
- ``set_levels`` passes a new value for each index in the level,
743
- where the new values to be passed in each level are defined in
744
- a list. It is assumed that a new value is provided for each
745
- code describing values in the level.
746
-
747
- If the number of values passed is more than the number of index
748
- values in the level, ``set_levels`` will still pass the values
749
- to the level. The passed values are stored in the FrozenList
750
- representing the levels attribute of the MultiIndex, even
751
- though the index values may be truncated in the MultiIndex
752
- output from set_levels.
753
-
754
742
Parameters
755
743
----------
756
744
levels : sequence or list of sequence
@@ -772,14 +760,6 @@ def set_levels(self, levels, level=None, inplace=False, verify_integrity=True):
772
760
(2, 'one'), (2, 'two'),
773
761
(3, 'one'), (3, 'two')],
774
762
names=['foo', 'bar'])
775
- >>> idx
776
- MultiIndex([('1', one),
777
- ('1', two),
778
- ('2', one),
779
- ('2', two),
780
- ('3', one),
781
- ('3', two)],
782
- names=['foo', 'bar'])
783
763
>>> idx.set_levels([['a', 'b', 'c'], [1, 2]])
784
764
MultiIndex([('a', 1),
785
765
('a', 2),
@@ -805,22 +785,10 @@ def set_levels(self, levels, level=None, inplace=False, verify_integrity=True):
805
785
(3, 'b')],
806
786
names=['foo', 'bar'])
807
787
808
- ``set_levels()`` passes values into the levels attribute that
809
- is represented by a FrozenList containing list of values for
810
- each level in the MultiIndex, even when the number of values
811
- passed for a level is more than the number of indexes
812
- available in the MultiIndex itself.
788
+ If any of the levels passed to ``set_levels()`` exceeds the
789
+ existing length, all of the values from that argument will
790
+ be stored though truncated in the MultiIndex output.
813
791
814
- >>> idx.set_levels([['a', 'b', 'c'], [1, 2]], level=[0, 1])
815
- MultiIndex([('a', 1),
816
- ('a', 2),
817
- ('b', 1),
818
- ('b', 2),
819
- ('c', 1),
820
- ('c', 2)],
821
- names=['foo', 'bar'])
822
- >>> idx.set_levels([['a', 'b', 'c'], [1, 2]], level=[0, 1]).levels
823
- FrozenList([['a', 'b', 'c'], [1, 2]])
824
792
>>> idx.set_levels([['a', 'b', 'c'], [1, 2, 3, 4]], level=[0, 1])
825
793
MultiIndex([('a', 1),
826
794
('a', 2),
0 commit comments