<jupyter_start><jupyter_text>Make bank configs for simulations<jupyter_code><agent identifier="SBSA">
<parameter type="state_variables" name="equity" value="86200249000.0"></parameter>
 <parameter type="parameters" name="leverage" value="13.0780116888061"></parameter>
 <parameter type="state_variables" name="debt" value="1127327864000.0"></parameter>
 <parameter type="parameters" name="m_1" value="0.0245212259042243" label="Cash and gold reserves "></parameter>
 <parameter type="parameters" name="m_2" value="0.0107197211672673" label="SA Interbank deposits, loans and advances "></parameter>
 <parameter type="parameters" name="m_3" value="0.00405856934605684" label="Rand Deposits with and loans to foreign banks"></parameter>
 <parameter type="parameters" name="m_4" value="0.0359414516505725" label="Loans granted under repo agreement"></parameter>
 <parameter type="parameters" name="m_5" value="0.129182760844701" label="Foreign currency loans and advances d 134),"></parameter>
 <parameter type="parameters" name="m_6" value="0.0170625845237423" label="Redeemable preference shares"></parameter>
 <parameter type="parameters" name="m_7" value="0.0296141684852751" label="corporate instalment credit "></parameter>
 <parameter type="parameters" name="m_8" value="0.0252157207337808" label="household instalment credit "></parameter>
 <parameter type="parameters" name="m_9" value="0.0690936667241429" label="corporate mortgage"></parameter>
 <parameter type="parameters" name="m_10" value="0.217515842585181" label="household mortgage"></parameter>
 <parameter type="parameters" name="m_11" value="0.114607784121438" label="Unsecured lending corporate"></parameter>
 <parameter type="parameters" name="m_12" value="0.0247813962262941" label="Unsecured lending households"></parameter>
 <parameter type="parameters" name="m_13" value="0.0589651490010434" label="Other credit (credit card + leasing + Overdarft + factoring debt)"></parameter>
 <parameter type="parameters" name="m_14" value="0.0412585423144622" label="Central and provincial government bonds"></parameter>
 <parameter type="parameters" name="m_15" value="0.00466172471770335" label="Other public-sector bonds"></parameter>
 <parameter type="parameters" name="m_16" value="0.0123382885320927" label="Private sector bonds"></parameter>
 <parameter type="parameters" name="m_17" value="0.000201706905161743" label="Equity holdings in subsidiaries and joint ventures"></parameter>
 <parameter type="parameters" name="m_18" value="0.0129940574355693" label="Listed and unlisted equities"></parameter>
 <parameter type="parameters" name="m_19" value="0.0839139051737815" label="Securitisation/ asset-backed securities"></parameter>
 <parameter type="parameters" name="m_20" value="0.00454473608062181" label="Derivative instruments"></parameter>
 <parameter type="parameters" name="m_21" value="0.0408429870466462" label="Treasury bills, SA Reserve Bank bills,  Land Bank bills "></parameter>
 <parameter type="parameters" name="m_22" value="0.00209378503289771" label="Other investments"></parameter>
 <parameter type="parameters" name="m_23" value="0.0358702254473441" label="Non financial assets"></parameter>
</agent><jupyter_output><empty_output><jupyter_text>Make overview table<jupyter_code>pwd

import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime
file_list=[]

import os
os.chdir('/Users/admin/git_repos/ba900/')

for filename in os.listdir('./data/output/'):
    if filename.endswith(".pkl")  and '2015' in filename or '2014' in filename:
        unpickle = './data/output/'+str(filename)
        print(unpickle)
        file_list.append(pd.read_pickle(unpickle))
 
 
MASTER = pd.concat(file_list)
MASTER['time'] = pd.to_datetime(MASTER['time'])
MASTER['Value'] = pd.to_numeric(MASTER['Value'])

import sys
import os
import sys
sys.path.append("..") 
 
from ba900 import assets_to_weights   

transform=assets_to_weights.tranformer()

from_=['ABSA BANK LTD ','THE STANDARD BANK OF S A LTD','FIRSTRAND BANK LIMITED ','NEDBANK LTD ','INVESTEC BANK LTD ',\
      'CITIBANK N.A ','CAPITEC BANK ' , 'AFRICAN BANK LIMITED ','JPMORGAN CHASE BANK             ',\
       'THE HONGKONG AND SHANGHAI BANKING CORPORATION LIMITED - JOHANNESBURG BRANCH ','STANDARD CHARTERED BANK ',\
       'CHINA CONSTRUCTION BANK         CORPORATION - JHB BRANCH '
      ]
to_=['ABSA', 'STANDARDBANK', 'FNB','NEDBANK', 'INVESTEC',\
    'CITYBANK','CAPITEC','AfricanB','JPM',\
     'HSBC','CHARTERED','ChinaConstruction']
renamed=transform.relabel_banknames(from_,to_,MASTER)
t=transform.get_biggest_banks( "2015", "12", renamed, 10)

top10=t.values.tolist()
renamed=renamed[renamed.InstitutionDescription.isin(top10)]
years = ['2014','2015']
months = ['12','11']

df=transform.get_overview_timeseries(top10,months,years,renamed)

# def get_overview_timeseries(banklist, months,years,dfrenamed):
#     import string
#     letters = list(string.ascii_uppercase)[:26]

#     temp1=[]
#     temp2=[]
#     temp3=[]
#     for y in years:
#         for m in months:
#             # Get bank totals for each of those strings 
#             for name,l in zip(banklist,letters):
#                 temp1.append(self.get_bank_totals(l,name,y, m, dfrenamed))

#             temp2.append(pd.concat(temp1))
#         temp3.append(pd.concat(temp2))
#     df=pd.concat(temp3)
#     df=df.drop_duplicates()
#     return df



d=transform.get_bank_totals(l,'FNB','2015', '11', renamed)
 
print(round(df4.iloc[0:1,-29:].sum(axis=1).values[0]))
renamed[renamed.InstitutionDescription=='FNB']
 # id	Name	Equity	Leverage	Debt	m1 Cash and gold reserves 
#  A 	SBSA	 86 200 249 000 	13.1	1127327864000	2.5%
#  C 	FNB	 75 526 054 370 	12.0	904393561840	2.7%
#  B 	ABSA	 57 255 883 000 	15.2	869270227000	2.8%
#  D 	NEDBANK	 57 683 474 000 	13.0	751035802000	2.9%
#  E 	INVESTEC	 24 265 229 000 	14.5	352780580000	1.9%
#  F 	CITYBANK	 5 123 291 030 	13.9	71388112090	0.8%
#  G 	CAPITEC	 13 056 412 000 	3.7	48913724000	5.8%
#  H 	AfricanB	 7 466 274 000 	6.8	50419037000	2.2%
#  I 	JPM	 3 246 873 000 	16.6	53788923000	0.3%
#  J 	HSBC	 3 919 312 000 	11.7	45886507000	1.9%
#  K 	CHARTERED	 3 688 896 000 	9.4	34731129000	1.7%
#  L 	BoCHINA	 4 178 651 000 	7.5	31464510000	1.1%
#  M 	DeutscheB	 1 433 355 000 	14.9	21321901000	0.1%
#  N 	BNP	 636 568 000 	21.8	13862348000	0.3%
#  O 	SOCIETEG	 666 836 000 	16.6	11058957000	1.3%


 
df3
debt/equity
 
absa_assets['InstitutionDescription'] = absa_assets['InstitutionDescription'].apply(lambda x: x.replace('ABSA BANK LTD ', 'ABSA'))

absa_assets
# id	Name	Equity	Leverage	Debt	m1 Cash and gold reserves 
#  A 	SBSA	 86 200 249 000 	13.1	1127327864000	2.5%
#  C 	FNB	 75 526 054 370 	12.0	904393561840	2.7%
#  B 	ABSA	 57 255 883 000 	15.2	869270227000	2.8%
#  D 	NEDBANK	 57 683 474 000 	13.0	751035802000	2.9%
#  E 	INVESTEC	 24 265 229 000 	14.5	352780580000	1.9%
#  F 	CITYBANK	 5 123 291 030 	13.9	71388112090	0.8%
#  G 	CAPITEC	 13 056 412 000 	3.7	48913724000	5.8%
#  H 	AfricanB	 7 466 274 000 	6.8	50419037000	2.2%
#  I 	JPM	 3 246 873 000 	16.6	53788923000	0.3%
#  J 	HSBC	 3 919 312 000 	11.7	45886507000	1.9%
#  K 	CHARTERED	 3 688 896 000 	9.4	34731129000	1.7%
#  L 	BoCHINA	 4 178 651 000 	7.5	31464510000	1.1%
#  M 	DeutscheB	 1 433 355 000 	14.9	21321901000	0.1%
#  N 	BNP	 636 568 000 	21.8	13862348000	0.3%
#  O 	SOCIETEG	 666 836 000 	16.6	11058957000	1.3%
THE STANDARD BANK OF S A LTD 
14                              FIRSTRAND BANK LIMITED 
14                                       ABSA BANK LTD 
14                                         NEDBANK LTD 
14                                   INVESTEC BANK LTD 
14                                        CAPITEC BANK 
14    THE HONGKONG AND SHANGHAI BANKING CORPORATION ...
14                                        CITIBANK N.A 
14                             STANDARD CHARTERED BANK 
14    CHINA CONSTRUCTION BANK         CORPORATION - ...
absa_equity.Value.values[0]+absa_debt.Value.values[0]
absa_equity=MASTER[(MASTER['TheYear']=='2008')&(MASTER['TheMonth']=='11')&
              (MASTER['InstitutionDescription']=='ABSA BANK LTD ')&(MASTER['ItemNumber']=='95')]
absa_equity<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12664334820890122, 'fraction_numerical': 0.16427451453383188, 'mean_word_length': 3.995180722891566, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '446911', 'license': 'MIT', 'n_tokens_mistral': 3974, 'n_tokens_neox': 3070, 'n_words': 743, 'path': 'processing/.ipynb_checkpoints/Make_bank_configs_overview_table-checkpoint.ipynb', 'repo_name': 't1nak/ba900', 'size': '8291'}