How to find index from raw and column in python

0 votes

I would like to use in np.put() function, but it requires, target indices, interpreted as integers.

[Problem:] I know raw and column, but now I need to find an index. In my case I have matrix 6 by 6 and I would like to find an index of data[3,3].

heatmap = np.zeros((6,6), dtype=int);
index? = someFuction(heatmap[r,c]);

I have tried to use functions like where(), enumerate() and shape(), but it didn't work.

It should be a very basic solution, but I couldn't find it anywhere online.

Sep 24, 2018 in Python by bug_seeker
• 15,520 points
1,239 views

1 answer to this question.

0 votes

You probably want to use np.ravel_multi_index:

import numpy as np
heatmap = np.zeros((6,6), dtype=int)
index = np.ravel_multi_index([[3], [3]], heatmap.shape)
print(index)
>>> [21]
answered Sep 24, 2018 by Priyaj
• 58,100 points

Related Questions In Python

0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,233 views
–1 vote
2 answers
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15, 2020 in Python by Niroj
• 82,880 points
6,659 views
0 votes
1 answer

How to handle AssertionError in Python and find out which line or statement it occurred on?

Use the traceback module: import sys import traceback try: ...READ MORE

answered Dec 18, 2018 in Python by charlie_brown
• 7,720 points
5,592 views
0 votes
1 answer

NumPy Array Indexing

If you want to create a subarray ...READ MORE

answered Jul 26, 2019 in Python by SDeb
• 13,300 points
645 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
934 views
0 votes
1 answer
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 58,100 points
883 views
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,270 points
1,971 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP