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
  Check if two matrix are equal and of not add the matrix to the list quest 3 790 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  search an element in pandas series learningPython 5 1,373 Apr-30-2023, 08:34 AM
Last Post: learningPython
  Sum the values in a pandas pivot table specific columns klllmmm 1 4,545 Nov-19-2021, 04:43 PM
Last Post: klllmmm
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,305 May-03-2021, 06:30 AM
Last Post: Gribouillis
  Bug ? when dataclass field name == field type Cyril 0 1,527 Oct-22-2020, 03:26 AM
Last Post: Cyril
  Finding an element in a 1d list in a 2d array lionrocker221 0 1,787 Jun-27-2020, 04:50 PM
Last Post: lionrocker221
  Remove isolated vertices from dictionary and adjacency matrix Weird 1 1,808 Jan-18-2020, 04:33 PM
Last Post: Weird
  Delete specific lines contain specific words mannyi 2 4,069 Nov-04-2019, 04:50 PM
Last Post: mannyi
  Finding a specific line in a file Vqlk 3 2,531 Sep-07-2019, 08:20 PM
Last Post: Axel_Erfurt
  Unable to locate element no such element gahhon 6 4,371 Feb-18-2019, 02:09 PM
Last Post: gahhon

Forum Jump:

User Panel Messages

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