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

A GeoDataFrame containing source geometry.

valuesstr, list, np.array, pd.Series

The name of the dataframe column, np.array, or pd.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.

percentilesarray-like (default [25, 50, 75])

The 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

A DataFrame 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.

__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)