Replace flat columns with hierarchical while merge
Is there is any standard method to replace flat columns with hierarchical while merge the dataframes?

I mean something like:


```python
def columns_as_multiindex(df, inplace=False):
    """Replace flat (:obj:`pandas.Index`) columns with hierarchical (:obj:`pandas.MultiIndex`).

    Parameters
    ----------
    df : pandas.DataFrame
        Dataframe wich contains the columns to be converted to MultiIndex.
    inplace : bool (default False)
        If ``True``, do operation inplace and return ``None``.

    Returns
    -------
    pandas.DataFrame or None
        Returns dataframe with modifed columns or ``None`` (depends on `inplace` parameter value).

    Examples
    --------
    >>> df0 = pd.DataFrame([[1,2], [10, 20], [100, 200]], columns=["A", "B"])
    >>> df0
    ...      A    B
    ... 0    1    2
    ... 1   10   20
    ... 2  100  200

    >>> columns = pd.MultiIndex.from_tuples([("C", "C0"), ("D", "D0")])
    >>> df1 = pd.DataFrame([[1,3], [10, 30], [100, 300]], columns=columns)
    >>> df1
    ...      C    D
    ...     C0   D0
    ... 0    1    3
    ... 1   10   30
    ... 2  100  300

    Merging ``df0`` with ``df1`` returns the dataframe contains tuples in the column names

    >>> df = pd.merge(df0, df1, left_on="A", right_on=[("C", "C0")])
    >>> df
    ...      A    B  (C, C0)  (D, D0)
    ... 0    1    2        1        3
    ... 1   10   20       10       30
    ... 2  100  200      100      300

    It's a bit ugly. Let's beautify the header

    >>> columns_as_multiindex(df)
    >>> df
    ...      A    B    C    D
    ...               C0   D0
    ... 0    1    2    1    3
    ... 1   10   20   10   30
    ... 2  100  200  100  300
    """
    columns = df.columns.tolist()
    columns = [(c,) if isinstance(c, str) or not np.iterable(c) else c for c in columns]
    max_len = max([len(c) for c in columns])
    columns = [tuple(c + ("",) * (max_len - len(c))) for c in columns]
    columns = pd.MultiIndex.from_tuples(columns)
    if inplace:
        df.columns = columns
    else:
        df_new = df.copy()
        df_new.columns = columns
        return df_new
```

**UPD 2019-06-13** A bit more robust function on input data.
