def counts_by_primary_id_squared(df):
    """Returns dict with IDs as keys and the number of data observations
    in the DataFrame argument as values.

    Args:
        df (pandas DataFrame):

    Returns:
        counts_by_id (dict): Dict.
    """
    return df.groupby(level=0).count().apply(lambda x: x ** 2).to_dict()
