def normalize_column_to_length(col, desired_count):
    """Given the value(s) for a column, normalize to a desired length.

    If `col` is a scalar, it's duplicated in a list the desired number of
    times.  If `col` is a list, it must have 0, 1, or the desired number of
    elements, in which cases `None` or the single element is duplicated, or
    the original list is returned.
    """
    desired_count = max(desired_count, 1)
    if isinstance(col, list) and len(col) == desired_count:
        return col
    elif isinstance(col, list):
        assert len(col) in (0, 1), (
            'Unexpectedly got a row with the incorrect number of '
            'repeated values.')
        return (col or [None]) * desired_count
    else:
        return [col] * desired_count