def MakePregMap(df):
 d = defaultdict(list)
 for (index, caseid) in df.caseid.iteritems():
  d[caseid].append(index)
 return d

def MakePregMap ( df ) : d = defaultdict ( list ) for ( index , caseid ) in df . caseid . iteritems ( ) : d [ caseid ] . append ( index ) return d
make a map from caseid to list of preg indices .