Python Forum

Full Version: finding element of specific field in pandas adjacency matrix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I have a pandas adjacency dataframe where I need to be able to identify any element on that dataframe by its physical numbered position, not index or column position, nor its coordinate.

the data frame is a 10,000 x 10,000 adjacency matrix:

(10103, 10103)
Instead of doing something like
adj.iloc[coord1], [coord2]]
(which works fine), i need to be able to find the value on the data frame by its physical number from 0 - 100,000,000 (0 being the very first field and 100,000,000 being the very last.

I have tried (what i believe is) a clunky way of doing which is to stack the dataframe, convert to list then find the appropriate value at the index i am interested in:

(or any other number which tells me what the value is at that position. this also works perfectly, but I would like to be able to keep the adjacency matrix intact. any help would be much appreciated!