<jupyter_start><jupyter_text>CPS Cleaning<jupyter_code>#reading in CPS data
cps = pd.read_csv("../data/raw/cps_00050.zip")
#creating CPS copy for manipulation
cps_cleaning = cps.copy()
#seeing data structure
cps_cleaning.shape
#reviewing CPS columns
cps_cleaning.columns
#isolating variables of interest
cps_cleaning = cps_cleaning[["YEAR", "MONTH", "REGION", "STATEFIP", "COUNTY", "BUNBANKED", "BUNDERBANKREAS", "BACCTEV", 
                             "BCHECKEV", "BCHECK12M", "BCHECKREAS", "BPAYDAY", "BPAYDAYOFT", "BPAYDAYREAS", "BCHECK30D", 
                             "BPAYDAY12M", "BPAYDAY30D", "BINCWHERE", "BBILLCASH", "BBILLCHECK", "BCREDITAPP", 
                             "BCREDITDENY", "BSAVECACCT", "BINC12M", "BINTERNET", "BPSUPINT"]]
#examining basic data statistics 
round(cps_cleaning.describe(), 2)
#examining null values as percentages
cps_cleaning.isnull().sum()/len(cps_cleaning)*100
#examining current data types
cps_cleaning.info()
#isolated those who responded to question battery about underbanked status
cps_cleaning_sub = cps_cleaning[cps_cleaning.BPSUPINT==1]
cps_cleaning_sub.BUNBANKED.value_counts()/len(cps_cleaning_sub)*100<jupyter_output><empty_output><jupyter_text>Of the subset selected, 93% are unbanked.<jupyter_code>#examining the breakdown of reasons alternative banking methods were utilized. 
cps_cleaning_sub.BUNDERBANKREAS.value_counts()
#Missing null data point percentages for sub population
cps_cleaning_sub.isnull().sum()*100/len(cps_cleaning_sub)
#examing dimentions of sub population after isolation
cps_cleaning_sub.shape
cps_cleaning_sub.describe()
#isolating underbanked population
cps_underbanked = cps_cleaning_sub[cps_cleaning_sub.BUNBANKED==1]
#Missing null data point percentages for unbanked population
cps_underbanked.isnull().sum()*100/len(cps_underbanked)
#examining the breakdown of why alternative banking is utilized
print("Missing Value Percentages:")
cps_underbanked.BCHECKEV.value_counts()*100/len(cps_underbanked)
cps_underbanked.BCHECKEV.describe()
cps_cleaning_sub.YEAR.value_counts()
cps_cleaning_sub.columns
list(cps_cleaning_sub.columns)[:5]
list(cps_cleaning_sub.columns)[5:]
categorical_cps_cleaning_sub = cps_cleaning_sub[['BUNBANKED', 'BUNDERBANKREAS', 'BACCTEV', 'BCHECKEV', 'BCHECK12M', 'BCHECKREAS', 'BPAYDAY',
                  'BPAYDAYOFT', 'BPAYDAYREAS', 'BCHECK30D', 'BPAYDAY12M', 'BPAYDAY30D', 'BINCWHERE', 'BBILLCASH',
                  'BBILLCHECK', 'BCREDITAPP', 'BCREDITDENY', 'BSAVECACCT', 'BINC12M', 'BINTERNET', 'BPSUPINT']]
categorical_cps_cleaning_sub.dtypes
imputed_KNN.shape
test = categorical_cps_cleaning_sub.head(5000)
imputer = KNNImputer(n_neighbors=3, weights="distance")
imputed_KNN = imputer.fit_transform(categorical_cps_cleaning_sub.head(5000))
imputed_KNN = pd.DataFrame(imputed_KNN, columns = categorical_cps_cleaning_sub.head(5000).columns)
cps_underbanked.shape
display(cps_underbanked.head(), cps_underbanked.tail())
cps_underbanked.isna().sum()
cps_underbanked.info()<jupyter_output><empty_output><jupyter_text>USA<jupyter_code>usa = pd.read_csv("../data/raw/usa_00005-002/usa_00005-002.csv")<jupyter_output><empty_output><jupyter_text>NFCS<jupyter_code>NFCS_2009 = pd.read_csv("../data/raw/NFCS 2009 State Data 130425.csv"")
NFCS_2012 = pd.read_csv("../data/raw/NFCS 2012 State Data 130503.csv"")
NFCS_2015 = pd.read_csv("../data/raw/NFCS 2015 State Tracking Data 160619.csv")
NFCS_2018 = pd.read_csv("../data/raw/NFCS 2018 State Data 190603.csv"")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.03775743707093822, 'mean_word_length': 6.736725663716814, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '570150', 'license': 'MIT', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1349, 'n_words': 214, 'path': 'notebooks/Team92_Project_Week7.ipynb', 'repo_name': 'neftali-guerrero-nav/An-Exploration-of-the-Unbanked-in-the-U.S.', 'size': '3496'}