def calculate_city_state_qty_delta(df):
    """
    This function creates the specific market growth (city + state observation) rate using quantity by doing the following:
    1. Creates the city_state_qty_delta_pop feature out of the quantity_of_mortgages_pop
    2. Creates the city_state_qty_delta_nc feature out of the quantity_of_mortgages_nc
    3. Returns the df with the new features
    """

    # create city_state_qty_delta_pop
    df["city_state_qty_delta_pop"] = df.sort_values(["year"]).groupby(["city", "state"])[["quantity_of_mortgages_pop"]].pct_change()

    # create city_state_qty_delta_nc
    df["city_state_qty_delta_nc"] = df.sort_values(["year"]).groupby(["city", "state"])[["quantity_of_mortgages_nc"]].pct_change()

    return df