Skip to content

Rook & KNN take different id lists from the dataframe #102

Open
@ljwolf

Description

@ljwolf

KNN correctly takes the index of the dataframe as the index of the weights, but rook does not.

from libpysal import weights
from libpysal import examples
import geopandas

columbus = geopandas.read_file(examples.get_path('columbus.shp'))
columbus_sub = columbus.sample(frac=1)

print(columbus_sub.index[0:5]) # should not be (0,1,2,3,4,) but instead random

Wr = weights.Rook.from_dataframe(columbus_sub)
Wknn1 = weights.KNN.from_dataframe(columbus_sub)

print(Wr.id_order) # is (0,1,2,3...)
print(Wknn1.id_order) # matches columbus_sub.index

These should behave the same everywhere, and I think they should behave like KNN, taking the indices from the dataframe directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs testinga pull request which needs testing added, or a bug/rough edge which exposes a functional testing gapno-issue-activityrough edgeSomething that's not a bug, but that gets in the way of "it just works."weights

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions