finding element of specific field in pandas adjacency matrix - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: finding element of specific field in pandas adjacency matrix (/thread-30588.html) |
finding element of specific field in pandas adjacency matrix - amjass12 - Oct-27-2020 Hi! 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: adj.shape (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: adj().stack().tolist()[0](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! thanks! |