sedona.spark.stats.autocorrelation package

Submodules

sedona.spark.stats.autocorrelation.moran module

class sedona.spark.stats.autocorrelation.moran.Moran[source]

Bases: object

Global 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 weights that lists each row’s neighbors and their weights, such as the one added by sedona.spark.stats.weighting.add_distance_band_column. Each neighbor must include the id and value columns, so pass them to the weighting function in saved_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: object

Result 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:

float

p_norm

p-value of z_norm under the normality assumption. It is two-tailed unless Moran.get_global was called with two_tailed=False.

Type:

float

z_norm

z-score of i under the normality assumption.

Type:

float

__init__(i: float, p_norm: float, z_norm: float) → None
i: float
p_norm: float
z_norm: float

Module contents