access.Access.enhanced_two_stage_fca¶
- Access.enhanced_two_stage_fca(name='e2sfca', cost=None, supply_values=None, max_cost=None, weight_fn=None, normalize=False)[source]¶
Calculate the enhanced two-stage floating catchment area access score. Note that the only ‘practical’ difference between this function and the
Access.access.two_stage_fca()
is that the weight function from the original paper, weights.step_fn({10 : 1, 20 : 0.68, 30 : 0.22}) is applied if none is provided.- Parameters:
- namestr
Column name for access values
- coststr
Name of cost value column in cost_df (supply-side)
- max_costfloat
Cutoff of cost values
- supply_values{str, list}
supply type or types.
- weight_fnfunction
Weight to be applied to access values
- normalizebool
If True, return normalized access values; otherwise, return raw access values
- Returns:
- accesspandas Series
Accessibility score for origin locations.
Examples
Import the base Access class and Datasets.
>>> from access import Access, Datasets
Load each of the example datasets:
>>> chi_docs_dents = Datasets.load_data('chi_doc') >>> chi_population = Datasets.load_data('chi_pop') >>> chi_travel_costs = Datasets.load_data('chi_times')
>>> chi_docs_dents.head() geoid doc dentist 0 17031010100 1 1 1 17031010201 0 1 2 17031010202 4 1 3 17031010300 4 1 4 17031010400 0 2
>>> chi_population.head() geoid pop 0 17031010100 4854 1 17031010201 6450 2 17031010202 2818 3 17031010300 6236 4 17031010400 5042
>>> chi_travel_costs.head() origin dest cost 0 17093890101 17031010100 91.20 1 17093890101 17031010201 92.82 2 17093890101 17031010202 92.95 3 17093890101 17031010300 89.40 4 17093890101 17031010400 84.97
Using the example data, create an Access object.
>>> chicago_primary_care = Access(demand_df = chi_population, demand_index = "geoid", demand_value = "pop", supply_df = chi_docs_dents, supply_index = "geoid", supply_value = ["doc", "dentist"], cost_df = chi_travel_costs, cost_origin = "origin", cost_dest = "destination", cost_name = "cost")
We can create multiple stepwise functions for weights.
>>> fn30 = weights.step_fn({10 : 1, 20 : 0.68, 30 : 0.22}) >>> fn60 = weights.step_fn({20 : 1, 40 : 0.68, 60 : 0.22})
Using those two difference stepwise functions, we can create two separate enhanced two stage fca measures.
>>> chicago_primary_care.enhanced_two_stage_fca(name = '2sfca30', weight_fn = fn30) 2sfca30_doc 2sfca30_dentist geoid 17031010100 0.000970 0.000461 17031010201 0.001080 0.000557 17031010202 0.001027 0.000531 ........... ........ ........ 17197884101 0.000159 0.000241 17197884103 0.000285 0.000342 17197980100 0.000266 0.000310
Note the use of the name argument in order to specify a different column name prefix for the access measure.
>>> chicago_primary_care.enhanced_two_stage_fca(name = '2sfca60', weight_fn = fn60) 2sfca60_doc 2sfca60_dentist geoid 17031010100 0.000687 0.000394 17031010201 0.000750 0.000447 17031010202 0.000720 0.000416 ........... ........ ........ 17197884101 0.000392 0.000301 17197884103 0.000289 0.000243 17197980100 0.000333 0.000268
Both newly created enhanced two stage fca measures are stored in the access_df attribute of the Access object.
>>> chicago_primary_care.access_df.head() pop 2sfca30_doc 2sfca30_dentist 2sfca60_doc 2sfca60_dentist geoid 17031010100 4854 0.000970 0.000461 0.000687 0.000394 17031010201 6450 0.001080 0.000557 0.000750 0.000447 17031010202 2818 0.001027 0.000531 0.000720 0.000416 17031010300 6236 0.001030 0.000496 0.000710 0.000402 17031010400 5042 0.000900 0.000514 0.000786 0.000430