momepy.Theil#
- class momepy.Theil(gdf, values, spatial_weights, unique_id, rng=None, verbose=True)[source]#
Calculates the Theil measure of inequality of values within neighbours defined in
spatial_weights
.Uses
inequality.theil.Theil
under the hood. Requires ‘inequality’ package.\[T = \sum_{i=1}^n \left( \frac{y_i}{\sum_{i=1}^n y_i} \ln \left[ N \frac{y_i} {\sum_{i=1}^n y_i}\right] \right)\]- Parameters
- gdfGeoDataFrame
GeoDataFrame containing morphological tessellation
- valuesstr, list, np.array, pd.Series
the name of the dataframe column,
np.array
, orpd.Series
where is stored character value.- spatial_weightslibpysal.weights
spatial weights matrix
- unique_idstr
name of the column with unique id used as
spatial_weights
index- rngTwo-element sequence containing floats in range of [0,100], optional
Percentiles over which to compute the range. Each must be between 0 and 100, inclusive. The order of the elements is not important.
- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
Examples
>>> sw = momepy.sw_high(k=3, gdf=tessellation_df, ids='uID') >>> tessellation_df['area_Theil'] = mm.Theil(tessellation_df, ... 'area', ... sw, ... 'uID').series 100%|██████████| 144/144 [00:00<00:00, 597.37it/s]
- Attributes
- seriesSeries
Series containing resulting values
- gdfGeoDataFrame
original GeoDataFrame
- valuesSeries
Series containing used values
- swlibpysal.weights
spatial weights matrix
- idSeries
Series containing used unique ID
- rngtuple, optional
range
Methods
__init__
(gdf, values, spatial_weights, unique_id)