Python Numpy 2d array with non-integer index

Viewed 2051

Background: I'm trying to build affinity matrix to feed into sklearn spectral clustering.

In this problem, I encounter the problem where numpy array indexes are 0-based integer, and for my application I'm using some sort of application specific ID (string-based, a random example "abc123"). I would like to create a 2d numpy array indexed by all the data points I have. For instance, given two points points = ["abc123", "xyz456"], I would have 2d numpy array whose row indices and column indexes are points. So that I could easily specify the distance between two points by something similar to arr["abc123"]["xyz456"] = dist

How could I achieve that? Thank you.

2 Answers
Related