def _encode_mixins(tbl):
    """Encode a Table ``tbl`` that may have mixin columns to a Table with only
    astropy Columns + appropriate meta-data to allow subsequent decoding.
    """
    from astropy.table import serialize
    from astropy.table.table import has_info_class
    from astropy import units as u
    from astropy.utils.data_info import MixinInfo, serialize_context_as
    try:
        import yaml
    except ImportError:
        for col in tbl.itercols():
            if has_info_class(col, MixinInfo
                ) and col.__class__ is not u.Quantity:
                raise TypeError(
                    "cannot write type {} column '{}' to HDF5 without PyYAML installed."
                    .format(col.__class__.__name__, col.info.name))
    with serialize_context_as('hdf5'):
        encode_tbl = serialize.represent_mixins_as_columns(tbl)
    return encode_tbl
