giddy
raw JSON → 2.3.8 verified Fri May 01 auth: no python
PySAL-giddy is a Python library for exploratory spatiotemporal data analysis, providing methods such as spatial Markov chains, rank-based Markov chains, and sequence analysis. Current version is 2.3.8, compatible with Python >=3.11. Releases are infrequent; the latest release was in 2025.
pip install giddy Common errors
error ImportError: cannot import name 'Spatial_Markov' from 'giddy' ↓
cause The symbol is not exported at the package level; it must be imported from the submodule.
fix
Use 'from giddy.markov import Spatial_Markov' instead of 'from giddy import Spatial_Markov'.
error ValueError: setting an array element with a sequence. ↓
cause Often occurs when providing ragged data (lists of different lengths) to Markov or Spatial_Markov.
fix
Ensure the input data is a 2D numpy array or rectangular list of lists with consistent dimensions.
Warnings
breaking In version 2.3.8, splot visualization code was moved into giddy itself. Previous imports from splot will break. Use giddy.viz instead. ↓
fix Update imports from 'splot' to 'giddy.viz'. For example, replace 'from splot.giddy import ...' with 'from giddy.viz import ...'.
deprecated The old 'giddy.mobility' module (functions like 'mobility_metrics') is deprecated and may be removed in future versions. Use 'giddy.markov' classes instead. ↓
fix Replace calls to giddy.mobility functions with the relevant Markov class methods (e.g., Markov.mobility).
gotcha Spatial_Markov requires a spatial weights object with the same number of observations as the data. Mismatched dimensions cause obscure errors. ↓
fix Ensure the weights object's 'n' attribute matches the number of rows in the data matrix.
gotcha The default fill value for missing transitions in Markov chains is set to a small epsilon, not zero. This can affect results when comparing with other implementations. ↓
fix Check the 'fill_value' parameter in Markov.__init__ and set it to 0 if desired.
Imports
- Markov
from giddy.markov import Markov - Spatial_Markov
from giddy.markov import Spatial_Markov - LISA_Markov
from giddy.markov import LISA_Markov - Tau
from giddy.ranking import Tau - Sequence
from giddy.sequence import Sequence - giddy wrong
from giddy import *correctimport giddy
Quickstart
import libpysal
from giddy.markov import Markov, Spatial_Markov
import numpy as np
# Create a simple transition matrix from random data
np.random.seed(100)
data = np.random.randint(0, 3, size=(10, 5))
m = Markov(data)
print(m.p)
print(m.classes)
# For spatial Markov, we need spatial weights
w = libpysal.weights.util.lat2W(4, 4)
# Ensure same number of spatial units as rows in data
# (this example is illustrative; actual use requires matching dimensions)