Python Forum
From theory to practice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
From theory to practice
#8
(Feb-24-2017, 04:51 PM)bertibott Wrote: This gives me an error that I do not understand in the slightest:
Error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Stackoverflow gives me many posts of people who have been getting this message while doing completely different things...
Generally you are going to want to use np.max and np.min in numpy contexts.  The builtin will work in one dimensional cases but not multi dimensional.
>>> a = np.array([4,5,6])
>>> max(a)
6
>>> a = np.array([[4,5,6],[5,6,7]])
>>> max(a)
Error:
Traceback (most recent call last):  File "<stdin>", line 1, in <module> ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
>>> np.max(a)
7
>>>
Reply


Messages In This Thread
From theory to practice - by bertibott - Feb-24-2017, 01:12 PM
RE: From theory to practice - by stranac - Feb-24-2017, 01:51 PM
RE: From theory to practice - by zivoni - Feb-24-2017, 02:19 PM
RE: From theory to practice - by bertibott - Feb-24-2017, 03:53 PM
RE: From theory to practice - by zivoni - Feb-24-2017, 04:55 PM
RE: From theory to practice - by Mekire - Feb-24-2017, 04:36 PM
RE: From theory to practice - by bertibott - Feb-24-2017, 04:51 PM
RE: From theory to practice - by zivoni - Feb-24-2017, 05:22 PM
RE: From theory to practice - by Mekire - Feb-24-2017, 05:07 PM
RE: From theory to practice - by bertibott - Feb-24-2017, 05:46 PM
RE: From theory to practice - by sparkz_alot - Feb-24-2017, 08:32 PM
RE: From theory to practice - by zivoni - Feb-24-2017, 09:37 PM
RE: From theory to practice - by sparkz_alot - Feb-25-2017, 12:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  .xls processing with Pandas - my struggle moving from theory to practical use prolle 0 1,555 May-21-2020, 06:57 PM
Last Post: prolle
  Help with Data Match Theory randor 2 2,033 Dec-25-2019, 05:57 PM
Last Post: randor

Forum Jump:

User Panel Messages

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