File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -756,11 +756,13 @@ def _index_level_unique_labels(idx, level):
756
756
# * if using .labels[level].values() gets unsupported at one point,
757
757
# simply use "unique_values = set(idx.get_level_values(level))" instead
758
758
759
+ level_num = idx ._get_level_number (level )
759
760
# .values() to get a straight ndarray from the FrozenNDArray that .labels[]
760
761
# gives us, which is slower to iterate on
761
762
# .astype(object) because set() needs python objects and it is faster to
762
763
# convert all ints in bulk than having them converted in the array iterator
763
- level_num = idx ._get_level_number (level )
764
- unique_labels = set (idx .labels [level_num ].values ().astype (object ))
764
+ # (it only pays for itself with len(unique) > ~100)
765
+ unique_labels = set (np .unique (idx .labels [level_num ].values ())
766
+ .astype (object ))
765
767
order = idx .levels [level_num ]
766
768
return [v for i , v in enumerate (order ) if i in unique_labels ]
You can’t perform that action at this time.
0 commit comments