Skip to content

Commit f527126

Browse files
committed
preserve order in contiguity
1 parent 91240dc commit f527126

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libpysal/weights/contiguity.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ def from_dataframe(
236236
if len(ids) != len(df):
237237
raise ValueError("The length of `ids` does not match the length of df.")
238238

239+
if id_order is None:
240+
id_order = ids
241+
239242
return cls.from_iterable(
240243
df[geom_col].tolist(), ids=ids, id_order=id_order, **kwargs
241244
)
@@ -519,6 +522,9 @@ def from_dataframe(
519522
if len(ids) != len(df):
520523
raise ValueError("The length of `ids` does not match the length of df.")
521524

525+
if id_order is None:
526+
id_order = ids
527+
522528
return cls.from_iterable(
523529
df[geom_col].tolist(), ids=ids, id_order=id_order, **kwargs
524530
)
@@ -639,7 +645,7 @@ def _from_dataframe(df, **kwargs):
639645
"""
640646
Construct a voronoi contiguity weight directly from a dataframe.
641647
Note that if criterion='rook', this is identical to the delaunay
642-
graph for the points.
648+
graph for the points if no clipping of the voronoi cells is applied.
643649
644650
If the input dataframe is of any other geometry type than "Point",
645651
a value error is raised.

0 commit comments

Comments
 (0)