Python Forum
Finding Row Number for Items in 2D array
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding Row Number for Items in 2D array
#3
(Jan-10-2019, 05:57 AM)scidam Wrote: No loops needed. Numpy can do all the work by itself:
three = three * np.arange(three.shape[0])[:, np.newaxis] # 0-based numbering # or three = three * np.arange(1, three.shape[0] + 1)[:, np.newaxis] # 1-based numbering 
This works neatly but I'm sorry I should have mentioned that I'm asked to do this using indexing and looping.

I was able to find a way and wanted to post back. Here's what worked
Thanks for the help

for i in range (0,5):
    three[i]=three[i]*(i+1)
Reply


Messages In This Thread
RE: Finding Row Number for Items in 2D array - by fafzal - Jan-10-2019, 06:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with array smallest biggest number thanikos 4 3,328 Nov-30-2017, 01:06 PM
Last Post: thanikos
  number of items per line kiki1113 3 8,118 Nov-19-2017, 04:53 PM
Last Post: nilamo
  Finding Number of Lowercase letters in a Set Steven 6 5,139 May-26-2017, 03:11 PM
Last Post: Steven

Forum Jump:

User Panel Messages

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