Skip to content

Commit acb43f6

Browse files
committed
Create FDIC_banks.py
1 parent 1ead42b commit acb43f6

File tree

2 files changed

+55
-19
lines changed

2 files changed

+55
-19
lines changed

‎VitalSigns/FDIC_banks.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
This notebook uses the Banks 2021 data to create a portion of BNIA's Vital Signs report
4+
5+
###Indicator from this csv
6+
* banks
7+
8+
###Tables used in this notebook
9+
* Banks_2021
10+
* CSA2010 to CSA2020 Crosswalk
11+
* 2020 Population
12+
"""
13+
14+
#export
15+
#Import needed libraries
16+
import pandas as pd
17+
18+
#Export
19+
#Read data
20+
banks = pd.read_excel("Banks_2021_CSA _City.xlsx")
21+
crosswalk = pd.read_csv("https://raw.githubusercontent.com/BNIA/VitalSigns/main/CSA2010_2020.csv")
22+
pop_2020 = pd.read_csv("CSA2020_CSA2010_&_2020pop.csv")
23+
24+
#Remove rows where Baltimore City is empty
25+
banks = banks[banks['BaltCity'] != '']
26+
27+
"""###banks"""
28+
29+
#Export
30+
#Banks Indicator
31+
#Rate of Banks and Bank Branches per 1,000 Residents
32+
33+
#Only keep needed columns
34+
banks = banks[['CSA']]
35+
36+
#Add counter
37+
banks['count'] = 1
38+
39+
#Add Baltimore City row
40+
banks.loc[len(banks.index)] = ['Baltimore City', banks['count'].sum()]
41+
42+
#Group by CSA
43+
banks = banks.groupby("CSA").sum()
44+
45+
#Append 2010 CSAs
46+
banks = crosswalk.merge(banks, left_on="CSA2020", right_on="CSA", how="outer")
47+
48+
#Append 2020 Population
49+
banks = banks.merge(pop_2020, on=["CSA2010", "CSA2020"], how='outer')
50+
51+
#Get banks indicator
52+
banks['banksXX'] = (banks['count'] / banks['tpop20']) * 1000
53+
54+
#Sort rows alphabetically
55+
banks = banks.sort_values('CSA2010')

‎VitalSigns/fdic.py‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)