Python Forum
finding element of specific field in pandas adjacency matrix
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
finding element of specific field in pandas adjacency matrix
#1
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 443 May-03-2021, 06:30 AM
Last Post: Gribouillis
  Bug ? when dataclass field name == field type Cyril 0 384 Oct-22-2020, 03:26 AM
Last Post: Cyril
  Finding an element in a 1d list in a 2d array lionrocker221 0 589 Jun-27-2020, 04:50 PM
Last Post: lionrocker221
  Remove isolated vertices from dictionary and adjacency matrix Weird 1 599 Jan-18-2020, 04:33 PM
Last Post: Weird
  Delete specific lines contain specific words mannyi 2 1,441 Nov-04-2019, 04:50 PM
Last Post: mannyi
  Finding a specific line in a file Vqlk 3 920 Sep-07-2019, 08:20 PM
Last Post: Axel_Erfurt
  Unable to locate element no such element gahhon 6 1,591 Feb-18-2019, 02:09 PM
Last Post: gahhon
  Finding all maximum values in a matrix Lightning1800 3 1,896 May-14-2018, 03:55 PM
Last Post: Lightning1800
  How to extract specific numbers from a matrix? Alberto 0 1,674 Mar-06-2018, 02:52 PM
Last Post: Alberto
  Newbie question for sum the specific element in named tuple zydjohn 1 2,536 Dec-12-2017, 07:29 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020