#NEWLINE# def individual_utilities( people , hh_id_col , p_type_col , one_spec , two_spec , three_spec ) : #NEWLINE# #INDENT# '\n    Calculate CDAP utilities for all individuals.\n\n    Parameters\n    ----------\n    people : pandas.DataFrame\n        DataFrame of individual people data.\n    hh_id_col : str\n        Name of the column in `people` that has their household ID.\n    p_type_col : str\n        Name of the column in `people` that contains the person type number.\n    one_spec : pandas.DataFrame\n        CDAP spec applied to individuals.\n    two_spec : pandas.DataFrame\n        CDAP spec applied to interactions between two people.\n    three_spec : pandas.DataFrame\n        CDAP spec applied to interactions between three people.\n\n    Returns\n    -------\n    utilities : pandas.DataFrame\n        Will have index of `people` and columns for each of the alternatives.\n\n    ' #NEWLINE# one_vars = eval_variables ( one_spec . index , people ) #NEWLINE# one_utils = one_vars . dot ( one_spec ) #NEWLINE# ( two_int , three_int ) = make_interactions ( people , hh_id_col , p_type_col ) #NEWLINE# two_vars = eval_variables ( two_spec . index , two_int ) #NEWLINE# two_utils = two_vars . dot ( two_spec ) . groupby ( level = 0 ) . sum ( ) #NEWLINE# three_vars = eval_variables ( three_spec . index , three_int ) #NEWLINE# three_utils = three_vars . dot ( three_spec ) . groupby ( level = 0 ) . sum ( ) #NEWLINE# utils = one_utils . add ( two_utils , fill_value = 0 ) . add ( three_vars , fill_value = 0 ) #NEWLINE# return utils