Python Forum
Loop for comparing 2 following datablocks in long Array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop for comparing 2 following datablocks in long Array
#1
Hallo everybody,

i search for an solution for following problem:

x=[1,2,3,4,5]
block_length=2
save=[]

for i in range (len(x)):

If np.std(Block i) > np.std(Block i-1):
np.append(save,np.max(,Block i))



This is just an example for what i´m programming in general.
If I do this in pur Python, without any tricks, it would be to tooo slow.

Sorry for the bad code discrption but i think it can be understand.
I know its no correct code

Thanks for every answer.

Greats
Sw1p3
Reply
#2
Hello, please edit your post so that the code is put within Python code tags. Also, use ctrl+shift+v when copying code, that will preserve indentation. You can find help here.
Reply
#3
if you are worried about a program being slow then you should do one of these two things:

1. use a better algorithm that works in fewer steps.

2. use a language other than Python since Python is intended for other purposes like faster coding and cleaner more clear code.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Loop over an an array of array Chendipeter 1 527 Nov-28-2023, 06:37 PM
Last Post: deanhystad
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 5,764 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  Loop different actions for an array Tibovdv 4 2,703 Mar-25-2021, 06:46 PM
Last Post: jefsummers
  Comparing Items Different Data Frames With a WHILE Loop JoeDainton123 1 1,926 Jul-30-2020, 04:11 AM
Last Post: scidam
  Double for loop with dates in array leifeng 1 1,597 Apr-05-2020, 03:27 PM
Last Post: leifeng
  Loop through array items dynamically in a certain format bhojendra 3 2,584 Jun-11-2019, 03:37 AM
Last Post: micseydel
  change array column values without loop khalidreemy 2 3,691 May-05-2019, 09:05 AM
Last Post: DeaD_EyE
  N-Dim array manipulation in a loop, getting IndexError: too many indices for array cesardepaula 1 4,413 Mar-13-2019, 01:39 AM
Last Post: scidam
  Putting an array for each string that is printed to a loop ClaudioSimonetti 1 2,315 Feb-05-2019, 12:52 PM
Last Post: perfringo
  action on MQTT while long loop is running runboy 4 6,029 Oct-05-2018, 11:57 PM
Last Post: runboy

Forum Jump:

User Panel Messages

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