def calculate_z_centr(df):
    """
    Assign the central z to each layer of an existing DataFrame.

    :param df: Original DataFrame.
    :return: Dataframe with the z_centr column.
    """
    return df.assign(z_centr=(df["zf"] + df["z_in"]) / 2)