Python Forum
How does the builtin function argpartition works?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does the builtin function argpartition works?
#1
Hi Frnds,

I'm new to numpy.. Can you please explain how the builtin function argpartition works?

>>> x = np.array([3, 4, 2, 1])
>>> x[np.argpartition(x, 3)]
array([2, 1, 3, 4])
>>> x[np.argpartition(x, (1, 3))]
array([1, 2, 3, 4])
>>>
>>> x = [3, 4, 2, 1]
>>> np.array(x)[np.argpartition(x, 3)]
array([2, 1, 3, 4])
I tried to understand the above example, but unfortunately I couldn't..:(
Reply


Messages In This Thread
How does the builtin function argpartition works? - by vicky53 - Apr-03-2019, 05:38 PM

Forum Jump:

User Panel Messages

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