Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A more efficient code
#1
I just started with Python. I want to add the information of the array ‘toc’ to the array ‘toc_n.’ The first two columns of both ones are ‘year’ and ‘day of the year,’ but the array ‘toc’ lacks some days (i.e., fewer rows). I wrote the following code. Could you please suggest something more efficient/clever?

for i in range(2196):
for j in range(2173):
dd = np.logical_and(toc_n[i,0] == toc[j,0] , toc_n[i,1] == toc[j,1])
if dd == True:
toc_n[i,2]=toc[j,2]
buran write Oct-16-2023, 11:06 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Reply


Messages In This Thread
A more efficient code - by titanif - Oct-16-2023, 10:49 AM
RE: A more efficient code - by Larz60+ - Oct-16-2023, 10:42 PM
RE: A more efficient code - by deanhystad - Oct-17-2023, 02:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cleaning my code to make it more efficient BSDevo 13 1,714 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Making a function more efficient CatorCanulis 9 2,180 Oct-06-2022, 07:47 AM
Last Post: DPaul
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,938 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  I there a more efficient way of printing ? Capitaine_Flam 7 3,758 Dec-01-2020, 10:37 AM
Last Post: buran
  Simple problem. looking for an efficient way silverchicken24 3 2,472 Oct-14-2019, 07:13 PM
Last Post: Larz60+
  Is there a more efficient way to code this project? gkiranseo 1 2,779 Sep-25-2018, 09:51 AM
Last Post: Larz60+
  Need help making code more efficient dhbergen 5 4,069 Apr-17-2018, 01:00 AM
Last Post: dhbergen

Forum Jump:

User Panel Messages

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