<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from google.colab import files
uploaded_files = files.upload()
#reading the file
census = pd.read_excel('2county2019.xlsx')
census.head(5)
#fixing the names
census['CTYNAME']=census['CTYNAME'].str.replace('County', '')
census['CTYNAME']=census['CTYNAME'].str.replace('Parish', '')
census['CTYNAME']=census['CTYNAME'].str.replace('Census Area', '')
census['CTYNAME']=census['CTYNAME'].str.replace('Burough', '')
census['CTYNAME']=census['CTYNAME'].str.replace('Municipality', '')
census['CTYNAME']=census['CTYNAME'].str.replace('City and Burough', '')
census['CTYNAME']=census['CTYNAME'].str.replace('city', '')

#census['CTYNAME']=census['CTYNAME'].str.split(' ',expand=True)[0:-1].str[:-1]

census['CTYNAME']=census['CTYNAME'].str.strip(' ')
census.head(5)
census['CountyState']= census['CTYNAME'].str.cat(census['STNAME'], sep =", ") 
census
#percentage of counties with >50% male or >50% female
fem_census = census['BFEM?'].value_counts("FEM")
fem_census
from google.colab import files
uploaded_files = files.upload()
#superfund data
superfunds = pd.read_csv("superfunds.csv")
superfunds.head(5)
active = superfunds[superfunds["Status"] == "NPL Site"].shape
proposed = superfunds[superfunds["Status"] == "Deleted NPL Site"].shape
deleted = superfunds[superfunds["Status"] == "Proposed NPL Site"].shape

(active, proposed, deleted)
superfunds['CountyState']= superfunds['County'].str.cat(superfunds['State'], sep =", ") 
superfunds.head(5)
superfunds_series = superfunds.set_index('CountyState').squeeze()
superfunds_series.head(5) 
census_nodrop = census
#counties with >13% black population
black_census = census[census["BAC_PER"] > 13]
black_census
#number of counties with >50% male or >50% female given >13% black population
black_fem_census1 = black_census['BFEM?'].value_counts()
black_fem_census1
#percentage of counties with >50% male or >50% female given >13% black population
black_fem_census2 = black_census['BFEM?'].value_counts("FEM")
black_fem_census2
black_census_series = black_census.set_index('CountyState').squeeze()
black_census_series
nodrop_series = census_nodrop.set_index('CountyState').squeeze()
nodrop_series
superfund_and_blackcensus = black_census_series.join(superfunds_series)

#remove any counties that aren't in the superfund dataset
superfund_and_blackcensus = superfund_and_blackcensus[superfund_and_blackcensus['Site Score'].notna()]
superfund_and_blackcensus.head(5)
superfund_and_nodrop = nodrop_series.join(superfunds_series)

#remove any counties that aren't in the superfund dataset
superfund_and_nodrop = superfund_and_nodrop[superfund_and_nodrop['Site Score'].notna()]
superfund_and_nodrop.head(200)
#number of counties with >50% male or >50% female given >13% black population and superfund site
sex1 = superfund_and_blackcensus['BFEM?'].value_counts()
sex1
#number of counties with >50% male or >50% female given >13% black population and superfund site
sex1 = superfund_and_blackcensus['BFEM?'].value_counts()
sex1
#percentage of counties with >50% male or >50% female given >13% black population and superfund site
sex2 = superfund_and_blackcensus['BFEM?'].value_counts('FEM')
sex2
superfund_and_nodrop['nonBI'] = superfund_and_nodrop['BAC_PER'] + superfund_and_nodrop['IAC_PER']
superfund_and_nodrop
plt.scatter(superfund_and_nodrop['nonBI'], superfund_and_nodrop['Site Score'], c='green', s=2, label="non Black or Indigenious")
plt.scatter(superfund_and_nodrop['BAC_PER'], superfund_and_nodrop['Site Score'], c='black', s=2, label="Black")
plt.scatter(superfund_and_nodrop['IAC_PER'], superfund_and_nodrop['Site Score'], c='brown', s=2, label="Indigenious")
plt.xlabel("% of residents")
plt.ylabel("superfund site score")
plt.figure()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15078125, 'fraction_numerical': 0.017708333333333333, 'mean_word_length': 9.215425531914894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '667742', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1363, 'n_words': 261, 'path': 'Census_Data.ipynb', 'repo_name': 'ertomz/h4bl-superfund-website', 'size': '3840'}