momepy.Unique#
- momepy.Unique(gdf, values, spatial_weights, unique_id, dropna=True, verbose=True)[source]#
Calculates the number of unique values within neighbours defined in
spatial_weights
.\[\]- Parameters:
- gdfGeoDataFrame
A GeoDataFrame containing morphological tessellation.
- valuesstr, list, np.array, pd.Series
The name of the dataframe column,
np.array
, orpd.Series
where character values are stored.- spatial_weightslibpysal.weights
A spatial weights matrix.
- unique_idstr
The name of the column with unique IDs used as the
spatial_weights
index.- dropnabool (default True)
Don’t include
NaN
in the counts of unique values.- verbosebool (default True)
If
True
, shows progress bars in loops and indication of steps.
- Attributes:
- seriesSeries
A Series containing resulting values.
- gdfGeoDataFrame
The original GeoDataFrame.
- valuesSeries
A Series containing used values.
- swlibpysal.weights
The spatial weights matrix.
- idSeries
A Series containing used unique ID.
Examples
>>> sw = momepy.sw_high(k=3, gdf=tessellation_df, ids='uID') >>> tessellation_df['cluster_unique'] = mm.Unique(tessellation_df, ... 'cluster', ... sw, ... 'uID').series 100%|██████████| 144/144 [00:00<00:00, 722.50it/s]