@@ -738,7 +738,7 @@ def create_level_from_collection(
738738 new_level : pandas .Index [Any ] = pd .Index (value , name = level )
739739 if not new_level .has_duplicates :
740740 # Fast route, can just return new level and codes from level we mapped from
741- return new_level , np .arange (len (value ))
741+ return new_level , list ( np .arange (len (value ) ))
742742 # Slow route, have to update the codes
743743 new_level = new_level .unique ()
744744 new_codes = new_level .get_indexer (value ) # type: ignore
@@ -772,7 +772,8 @@ def set_levels(
772772 TypeError
773773 If `ini` is not a MultiIndex
774774 ValueError
775- If the length of the values is a collection that is not equal to the length of the index
775+ If the length of the values is a collection that is not equal to the
776+ length of the index
776777
777778 Examples
778779 --------
@@ -840,7 +841,7 @@ def set_levels(
840841 new_level , new_codes = create_level_from_collection (level , value )
841842 else :
842843 new_level = pd .Index ([value ], name = level )
843- new_codes = np .zeros (ini .shape [0 ])
844+ new_codes = list ( np .zeros (ini .shape [0 ]) )
844845
845846 if level in ini .names :
846847 level_idx = ini .names .index (level )
@@ -892,6 +893,6 @@ def set_index_levels_func(
892893 if copy :
893894 df = df .copy ()
894895
895- df .index = set_levels (df .index , levels_to_set = levels_to_set )
896+ df .index = set_levels (df .index , levels_to_set = levels_to_set ) # type: ignore
896897
897898 return df
0 commit comments