From fbce9b1288284dc69f36cbfb76ccc6f49e9c74a6 Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Wed, 3 May 2017 16:40:52 -0400 Subject: [PATCH 1/3] packaging data for borrower schedule --- bpfin/financials/borrower_schedule.py | 63 +++++++++++++++++++++++++++ bpfin/financials/cash_balance.py | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 bpfin/financials/borrower_schedule.py diff --git a/bpfin/financials/borrower_schedule.py b/bpfin/financials/borrower_schedule.py new file mode 100644 index 0000000..0d44cf6 --- /dev/null +++ b/bpfin/financials/borrower_schedule.py @@ -0,0 +1,63 @@ +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np + + +def packaging_data(analysis_date, energy_expenses, loan_input, savings_input): + + analysis_years = {} + + for date in analysis_date: + start_year = date.year + duration = analysis_date[date] + for i in range(duration): + analysis_years[start_year + i] = [] + + #not correct + for date in analysis_date: + if date in energy_expenses: + analysis_date[date].append(energy_expenses[date]) + if date in loan_input: + analysis_date[date].append(loan_input[date]) + if date in savings_input: + analysis_date[date].append(savings_input[date]) + + # raw_data = { + # 'years': years, + # 'energy_expenses': energy_expenses, + # 'loan_input': loan_input, + # 'savings_input': savings_input + # } + # df = pd.DataFrame( + # raw_data, + # columns=['years', 'energy_expenses', 'loan_input', 'savings_input']) + # f, ax1 = plt.subplots(1, figsize(10, 5)) + # bar_width = 0.75 + # bar_l = [i + 1 for i in range(len(df['energy_expenses']))] + # tick_pos = [i + (bar_width / 2) for i in bar_l] + # ax1.bar( + # bar_l, + # df['energy_expenses'], + # width=bar_width, + # label='Energy Expenses', + # alpha=0.5, + # color='#F4561D') + # ax1.bar( + # bar_l, + # df['loan_input'], + # width=bar_width, + # label='Loan Value', + # alpha=0.5, + # color='#F1911E') + # ax1.bar( + # bar_l, + # df['savings_input'], + # width=bar_width, + # label='Net Savings to Customer', + # alpha=0.5, + # color='#F1BD1A') + # plt.xticks(tick_pos, df['year']) + # ax1.set_ylabel("$") + # ax1.set_xlabel("Year") + # plt.legend(loc='upper left') + # plt.xlim([min(tick_pos) - bar_width, max(tick_pos) + bar_width]) diff --git a/bpfin/financials/cash_balance.py b/bpfin/financials/cash_balance.py index a73675d..55cd11c 100644 --- a/bpfin/financials/cash_balance.py +++ b/bpfin/financials/cash_balance.py @@ -21,5 +21,5 @@ def cash_balance(cash_dictionary): for year, value in bank_statement.items(): if year not in cash_balance_dictionary: - cash_balance_dictionary[year] = sum(value)/len(value) + cash_balance_dictionary[year] = sum(value) / len(value) return cash_balance_dictionary -- GitLab From e8692f50a4d00023f5b96dc51c303e4c3db15f69 Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Wed, 3 May 2017 17:48:01 -0400 Subject: [PATCH 2/3] Create borrower schedule information for graphs --- bpfin/financials/borrower_schedule.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bpfin/financials/borrower_schedule.py b/bpfin/financials/borrower_schedule.py index 0d44cf6..86b75db 100644 --- a/bpfin/financials/borrower_schedule.py +++ b/bpfin/financials/borrower_schedule.py @@ -13,14 +13,17 @@ def packaging_data(analysis_date, energy_expenses, loan_input, savings_input): for i in range(duration): analysis_years[start_year + i] = [] - #not correct - for date in analysis_date: + for date in analysis_years: + data_storage = {} if date in energy_expenses: - analysis_date[date].append(energy_expenses[date]) + data_storage['energy_expenses'] = energy_expenses[date] if date in loan_input: - analysis_date[date].append(loan_input[date]) + data_storage['loan_input'] = loan_input[date] if date in savings_input: - analysis_date[date].append(savings_input[date]) + data_storage['savings_input'] = savings_input[date] + analysis_years[date] = data_storage + + return analysis_years # raw_data = { # 'years': years, -- GitLab From 9f20a04c0ca53f4f4c81685efba6cda01b1e2791 Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Wed, 3 May 2017 18:16:29 -0400 Subject: [PATCH 3/3] Name change --- bpfin/financials/borrower_schedule.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bpfin/financials/borrower_schedule.py b/bpfin/financials/borrower_schedule.py index 86b75db..a9b59ac 100644 --- a/bpfin/financials/borrower_schedule.py +++ b/bpfin/financials/borrower_schedule.py @@ -13,15 +13,15 @@ def packaging_data(analysis_date, energy_expenses, loan_input, savings_input): for i in range(duration): analysis_years[start_year + i] = [] - for date in analysis_years: + for year in analysis_years: data_storage = {} - if date in energy_expenses: - data_storage['energy_expenses'] = energy_expenses[date] - if date in loan_input: - data_storage['loan_input'] = loan_input[date] - if date in savings_input: - data_storage['savings_input'] = savings_input[date] - analysis_years[date] = data_storage + if year in energy_expenses: + data_storage['energy_expenses'] = energy_expenses[year] + if year in loan_input: + data_storage['loan_input'] = loan_input[year] + if year in savings_input: + data_storage['savings_input'] = savings_input[year] + analysis_years[year] = data_storage return analysis_years -- GitLab