sedona.spark.stats.autocorrelation package
Submodules
sedona.spark.stats.autocorrelation.moran module
- class sedona.spark.stats.autocorrelation.moran.Moran[source]
Bases:
objectGlobal Moran’s I spatial autocorrelation test.
- static get_global(df: DataFrame, two_tailed: bool = True, id_column: str = 'id', value_column: str = 'value') MoranResult[source]
Computes the global Moran’s I of a value column.
The dataframe needs an id column that uniquely identifies each row, a numeric value column, and a column named
weightsthat lists each row’s neighbors and their weights, such as the one added bysedona.spark.stats.weighting.add_distance_band_column. Each neighbor must include the id and value columns, so pass them to the weighting function insaved_attributes.- Parameters:
df – dataframe with the id, value, and weights columns
two_tailed – whether to return a two-tailed p-value. Default is True
id_column – name of the column that identifies each row. Default is “id”
value_column – name of the numeric column to test. Default is “value”
- Returns:
A MoranResult with Moran’s I and its z-score and p-value under the normality assumption.
- class sedona.spark.stats.autocorrelation.moran.MoranResult(i: float, p_norm: float, z_norm: float)[source]
Bases:
objectResult of the global Moran’s I test.
- i
Moran’s I. Values near 1 mean that similar values are close to each other, values near -1 mean that neighbors tend to have dissimilar values, and values near 0 mean that the values are randomly distributed.
- Type:
- p_norm
p-value of
z_normunder the normality assumption. It is two-tailed unlessMoran.get_globalwas called withtwo_tailed=False.- Type: