Python Forum
Removing some elements from array based on a condition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing some elements from array based on a condition
#1
Hi, I have this matlab code

A(A> numel(B)) = [ ];

where A and B are two arrays.

The code above, as I interpreted it, removes some of the elements in the A array based on the condition in the brackets.

I want to do the same in Python.

In an easier Matlab case like A(B) = [ ]

I simply would do

A= np.delete(A, B, axis = 0)
What about the above condition?

Would something like

A= np.delete(A, A >  B.size, axis = 0)
be correct?

Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to remove all elements from list based on a condition sg_python 3 442 Jan-27-2024, 04:03 PM
Last Post: deanhystad
  How to remove some elements from an array in python? gohanhango 9 1,163 Nov-28-2023, 08:35 AM
Last Post: Gribouillis
  Sent email based on if condition stewietopg 1 863 Mar-15-2023, 08:54 AM
Last Post: menator01
  create new column based on condition arvin 12 2,247 Dec-13-2022, 04:53 PM
Last Post: jefsummers
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 839 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,139 May-17-2022, 11:38 AM
Last Post: Larz60+
  Replace elements of array with elements from another array based on a third array Cola_Reb 6 1,861 May-13-2022, 06:06 PM
Last Post: deanhystad
Question Change elements of array based on position of input data Cola_Reb 6 2,131 May-13-2022, 12:57 PM
Last Post: Cola_Reb
  select Eof extension files based on text list of filenames with if condition RolanRoll 1 1,515 Apr-04-2022, 09:29 PM
Last Post: Larz60+
  Calculate next rows based on previous values of array divon 0 1,778 Nov-23-2021, 04:44 AM
Last Post: divon

Forum Jump:

User Panel Messages

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