access.Access.two_stage_fca

Access.two_stage_fca(name='2sfca', cost=None, max_cost=None, supply_values=None, weight_fn=None, normalize=False)[source]

Calculate the two-stage floating catchment area access score. Note that while the ‘traditional’ 2SFCA method does not weight inputs, most modern implementations do, and weight_fn is allowed as an argument.

Parameters:
namestr

Column name for access values

coststr

Name of cost value column in cost_df (supply-side)

supply_values{str, list}

supply type or types.

max_costfloat

Cutoff of cost values

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",
                                  neighbor_cost_df = chi_travel_costs, neighbor_cost_origin = "origin",
                                  neighbor_cost_dest = 'dest', neighbor_cost_name = 'cost')
>>> chicago_primary_care.two_stage_fca(name = '2sfca', max_cost = 60)
              pop  2sfca_doc  2sfca_dentist
geoid
17031010100  4854   0.000697       0.000402
17031010201  6450   0.000754       0.000455
17031010202  2818   0.000717       0.000424
...........  ....   ........       ........
17197884101  4166   0.000562       0.000370
17197884103  2776   0.000384       0.000291
17197980100  3264   0.000457       0.000325

To create new values for two-stage catchment areas using a different max_cost, you can use a new name and a different max_cost parameter.

>>> chicago_primary_care.two_stage_fca(name = '2sfca30', max_cost = 30)
             2sfca30_doc  2sfca30_dentist
geoid
17031010100     0.000966         0.000480
17031010201     0.000996         0.000552
17031010202     0.000973         0.000542
...........     ........         ........
17197884101     0.000225         0.000258
17197884103     0.000375         0.000382
17197980100     0.000352         0.000318

Both newly created two stage fca measures are stored in the access_df attribute of the Access object.

>>> chicago_primary_care.access_df.head()
              pop  2sfca_doc  2sfca_dentist  2sfca30_doc  2sfca30_dentist
geoid
17031010100  4854   0.000697       0.000402     0.000963         0.000479
17031010201  6450   0.000754       0.000455     0.000991         0.000551
17031010202  2818   0.000717       0.000424     0.000973         0.000541
17197884103  2776   0.000384       0.000291     0.000371         0.000377
17197980100  3264   0.000457       0.000325     0.000348         0.000314