def quantile_normalize(df):
    """Apply quantile normalization to input dataframe.

    Parameters
    ----------
    df: pd.DataFrame
        Input data frame.

    Returns
    -------
    pd.DataFrame
        Transformed output data frame.
    """
    rank_mean = df.stack().groupby(df.rank(method="first").stack().astype(int)).mean()
    return df.rank(method="min").stack().astype(int).map(rank_mean).unstack()