momepy.Percentiles#
- class momepy.Percentiles(gdf, values, spatial_weights, unique_id, percentiles=[25, 50, 75], interpolation='midpoint', verbose=True, weighted=None)[source]#
Calculates the percentiles of values within neighbours defined in
spatial_weights
.- Parameters
- gdfGeoDataFrame
GeoDataFrame containing source geometry
- 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- percentilesarray-like (default [25, 50, 75])
percentiles to return
- interpolation{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
This optional parameter specifies the interpolation method to use when the desired percentile lies between two data points
i < j
:'linear'
'lower'
'higher'
'nearest'
'midpoint'
See the documentation of
numpy.percentile
for details.- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
- weighted{‘linear’, None} (default None)
Distance decay weighting. If None, each neighbor within spatial_weights has equal weight. If linear, linear inverse distance between centroids is used as a weight.
Examples
>>> sw = momepy.sw_high(k=3, gdf=tessellation_df, ids='uID') >>> percentiles_df = mm.Percentiles(tessellation_df, ... 'area', ... sw, ... 'uID').frame 100%|██████████| 144/144 [00:00<00:00, 722.50it/s]
- Attributes
- frameDataFrame
DataFrame containing resulting values
- gdfGeoDataFrame
original GeoDataFrame
- valuesSeries
Series containing used values
- swlibpysal.weights
spatial weights matrix
- idSeries
Series containing used unique ID
- __init__(gdf, values, spatial_weights, unique_id, percentiles=[25, 50, 75], interpolation='midpoint', verbose=True, weighted=None)[source]#
Methods
__init__
(gdf, values, spatial_weights, unique_id)