code: def facetcolumns(table, key, missing=None):
      
  
      fct = dict()
      it = iter(table)
      hdr = next(it)
      flds = list(map(text_type, hdr))
      indices = asindices(hdr, key)
      assert len(indices) > 0, 'no key field selected'
      getkey = operator.itemgetter(*indices)
  
      for row in it:
          kv = getkey(row)
          if kv not in fct:
              cols = dict()
              for f in flds:
                  cols[f] = list()
              fct[kv] = cols
          else:
              cols = fct[kv]
          for f, v in izip_longest(flds, row, fillvalue=missing):
              if f in cols:
                  cols[f].append(v)
  
      return fct
docs: Like :func:`petl.util.materialise.columns` but stratified by values of the
      given key field. E.g.::
  
          >>> import petl as etl
          >>> table = [['foo', 'bar', 'baz'],
          ...          ['a', 1, True],
          ...          ['b', 2, True],
          ...          ['b', 3]]
          >>> fc = etl.facetcolumns(table, 'foo')
          >>> fc['a']
          {'foo': ['a'], 'bar': [1], 'baz': [True]}
          >>> fc['b']
          {'foo': ['b', 'b'], 'bar': [2, 3], 'baz': [True, None]}