individual_total_payments

individual_total_payments

Module for calculating how much each person actually paid.

Functions

Name Description
individual_total_payments Calculate the net amount to pay per item and return a dataframe with the total payment amount per person.

individual_total_payments

individual_total_payments.individual_total_payments(valid_df)

Calculate the net amount to pay per item and return a dataframe with the total payment amount per person.

First, this function takes in valid payments dataframe and derives a new column ‘item_paymant’ which is the total cost of each item including tax and tip. Then, it groups the datafram by the person who originally paid for the item and sums up the cost.

Parameters

Name Type Description Default
valid_df pandas.DataFrame A dataframe containing validated data read from the input CSV file. Typically the output of load_validate_data() function. required

Returns

Name Type Description
actually_paid_df pandas.DataFrame Dataframe with columns ‘payer’ and ‘actually_paid’.

Examples

>>> valid_df
    payer   item_name  item_price  shared_by  tax_pct  tip_pct
0   Leo     candy      10.0        Leo        0.12     0.15
1   Leo     taxi       25.0        Leo;Ana    0.07     0.0
2   Ana     lunch      20.0        Ana        0.12     0.15
>>> individual_total_payments(valid_df)
    name   actually_paid
0   Leo     39.45
1   Ana     25.40