<jupyter_start><jupyter_text>Community Assests Analysis and Street/School Scores  ConfigurationLoad the software packages needed.<jupyter_code>import numpy as np 
import pandas as pd
import community_profiles.datasets as cp_data<jupyter_output><empty_output><jupyter_text>Load the data<jupyter_code>facility = cp_data.CityOwned.get()
library = facility.loc[facility['ASSET_GROU'] == 'Libraries'] 
playground = facility.loc[facility['ASSET_SUBT'] == 'Playground']

parks = cp_data.Parks.get()

hospitals = cp_data.Hospitals.get() 
health_centers = cp_data.HealthCenters.get() 

schools = cp_data.Schools.get()
score = cp_data.SchoolScores.get()
litter = cp_data.LitterIndex.get()
condition = cp_data.StreetCondition.get() 

new_construction = cp_data.NewConstruction.get()<jupyter_output><empty_output><jupyter_text>Community Assets<jupyter_code>asset = [library, playground, parks,  hospitals, health_centers, schools]
list_asset = []
for i in asset:
    list_asset.append(cp_data.puma_count(i))
    
puma_assets = pd.concat(list_asset, axis =1 ).rename(columns={0: 'library', 1: 'playground', 
                                                              2 :'parks',  3 :'hospitals', 
                                                              4 :'health centers', 5 : 'schools'})<jupyter_output><empty_output><jupyter_text>Other indicators school score<jupyter_code># score['school group'] = pd.cut(score['Overall Sc'], bins=[0, 24, 49, 74, 100], labels=False)
# labels = np.array('Score:0-24 Score:25-49 Score:50-74 Score:75-100'.split())
# score['school group'] = labels[score['school group']]<jupyter_output><empty_output><jupyter_text>Street condition score ( % with score of 30 or lower (good condition))<jupyter_code># cut data to streets with rating less than 30 
little_defect = condition.loc[condition['rating'] < 30 ]

# count all streets in data 
all_streets = cp_data.puma_count(condition)

# percent in good condition
good_streets = cp_data.puma_count(little_defect, normalize = True, total = all_streets)<jupyter_output><empty_output><jupyter_text>% Streets with little to no litter<jupyter_code># litter index score for 2018
litter = litter.loc[litter['YEAR'] == 2018] 
# cut data to streets with little to no litter 
clean = litter.loc[(litter['score'] < 2) & (litter['score'] > 0)]

# count all streets in data
litter_streets = cp_data.puma_count(litter)

# percent of streets with little to no litter
clean_streets = cp_data.puma_count(clean, normalize = True, total = litter_streets)<jupyter_output><empty_output><jupyter_text>Number of new construction permits<jupyter_code>new_con = cp_data.puma_count(new_construction)<jupyter_output><empty_output><jupyter_text>Combine into one dataframe<jupyter_code>#combine series into dataframe
d = {'good_streets' : good_streets,
    'clean_streets' : clean_streets,
    'new_construction_permits' : new_con }
df = pd.DataFrame(d)

# combine all dataframes together
df = pd.concat((puma_assets, df), axis =1 )
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11698238617480891, 'fraction_numerical': 0.01661681621801263, 'mean_word_length': 5.244813278008299, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '408944', 'license': 'MIT', 'n_tokens_mistral': 1059, 'n_tokens_neox': 997, 'n_words': 217, 'path': 'community_assets.ipynb', 'repo_name': 'nickhand/community-profiles', 'size': '3009'}