segregation.compute_all.ComputeAllSegregation¶
-
class
segregation.compute_all.
ComputeAllSegregation
(data, group_pop_var, total_pop_var)[source]¶ Perform point estimation of selected segregation measures at once
- Parameters
- dataa pandas DataFrame
- group_pop_varstring
The name of variable in data that contains the population size of the group of interest
- total_pop_varstring
The name of variable in data that contains the total population of the unit
Examples
The Compute_All comprises simple and quick functions to assess multiple segregation measures at once in a dataset. It uses all the default parameters and returns an object that has an attribute (.computed) of a dictionary with summary of all values fitted.
Firstly, we need to import the libraries and functions to be used.
>>> import geopandas as gpd >>> import segregation >>> import libpysal >>> from segregation.util import ComputeAllSegregation
Then it’s time to load some data to estimate segregation. We use the data of 2000 Census Tract Data for the metropolitan area of Sacramento, CA, USA.
We use a geopandas dataframe available in PySAL examples repository.
For more information about the data: https://github.com/pysal/libpysal/tree/master/libpysal/examples/sacramento2
>>> s_map = gpd.read_file(libpysal.examples.get_path("sacramentot2.shp"))
The data have several demographic variables. We are going to assess the segregation of the Hispanic Population (variable ‘HISP_’). For this, we only extract some columns of the geopandas dataframe.
>>> gdf = s_map[['geometry', 'HISP_', 'TOT_POP']]
Now the measures are fitted.
>>> segregation_fit = ComputeAllSegregation(gdf, 'HISP_', 'TOT_POP') >>> segregation_fit.computed
- Attributes
- computeda pandas DataFrame containing the name of the measure and the point estimation.
-
__init__
(data, group_pop_var, total_pop_var)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(data, group_pop_var, total_pop_var)Initialize self.