def group_table_indices(table, key_vars, exclude_unknown=False):
 groups = defaultdict(list)
 for (i, inst) in enumerate(table):
  key = [(inst.id if (a == INSTANCEID) else (i if (a == INDEX) else inst[a])) for a in key_vars]
  if (exclude_unknown and any((math.isnan(k) for k in key))):
   continue
  key = tuple([str(k) for k in key])
  groups[key].append(i)
 return groups

def group_table_indices ( table , key_vars , exclude_unknown = False ) : groups = defaultdict ( list ) for ( i , inst ) in enumerate ( table ) : key = [ ( inst . id if ( a == INSTANCEID ) else ( i if ( a == INDEX ) else inst [ a ] ) ) for a in key_vars ] if ( exclude_unknown and any ( ( math . isnan ( k ) for k in key ) ) ) : continue key = tuple ( [ str ( k ) for k in key ] ) groups [ key ] . append ( i ) return groups
group table indices based on values of selected columns .