def _get_level_lengths(index):
 sentinel = com.sentinel_factory()
 levels = index.format(sparsify=sentinel, adjoin=False, names=False)
 if (index.nlevels == 1):
  return {(0, i): 1 for (i, value) in enumerate(levels)}
 lengths = {}
 for (i, lvl) in enumerate(levels):
  for (j, row) in enumerate(lvl):
   if (not get_option('display.multi_sparse')):
    lengths[(i, j)] = 1
   elif (row != sentinel):
    last_label = j
    lengths[(i, last_label)] = 1
   else:
    lengths[(i, last_label)] += 1
 return lengths

def _get_level_lengths ( index ) : sentinel = com . sentinel_factory ( ) levels = index . format ( sparsify = sentinel , adjoin = False , names = False ) if ( index . nlevels == 1 ) : return { ( 0 , i ) : 1 for ( i , value ) in enumerate ( levels ) } lengths = { } for ( i , lvl ) in enumerate ( levels ) : for ( j , row ) in enumerate ( lvl ) : if ( not get_option ( 'display.multi_sparse' ) ) : lengths [ ( i , j ) ] = 1 elif ( row != sentinel ) : last_label = j lengths [ ( i , last_label ) ] = 1 else : lengths [ ( i , last_label ) ] += 1 return lengths
given an index .