def index_union(df_src, df_target, use_target_names=True):
    """
    Create the union of the indices for the two Pandas DataFrames.
    This combines the "rows" of the two indices, so the index-types
    must be identical.

    :param df_src: Pandas Series or DataFrame.

    :param df_target: Pandas Series or DataFrame.

    :param use_target_names:
        Boolean whether to use the index-names
        from `df_target` (True) or `df_src` (False).

    :return: Pandas Index.
    """

    # This is not a "deep" type comparison. Two MultiIndex could be different.
    assert (type(df_src.index) == type(df_target.index))

    # Create the union of the indices.
    # This does not copy the index-names.
    idx = df_src.index.union(df_target.index)

    if use_target_names:
        # Use the index-names from the target.
        # This is similar to Pandas' reindex.
        idx.names = df_target.index.names
    else:
        # Use the index-names from the source.
        idx.names = df_src.index.names

    return idx