Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
type error array
#3
(Jan-17-2021, 03:00 AM)deanhystad Wrote:
Quote:numpy.array(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0)

Parameters
object : array_like
An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence.
You can do np.array([1, 2, 3, 4, 5]) but you cannot do np.array(1, 2, 3, 4, 5)

You can use a list comprehension to replace all those error prone subtractions.
Thanks deanhystad!
I do indeed have a lot more to learn. The list comprehension you wrote is something I definitely have to get more knowledge about.
The array initially was created like np.array([1, 2, 3, 4, 5]). I got quite a few errors when it was coded like that. Tried many different things to correct the errors, and never changed it back. I guess that is where the list comprehension would solve that. You have given me an example on how to improve upon what I was doing wrong, and also what to investigate on learning what to do in the future. For that, I thank you!
Reply


Messages In This Thread
type error array - by BrianPA - Jan-17-2021, 02:01 AM
RE: type error array - by deanhystad - Jan-17-2021, 03:00 AM
RE: type error array - by BrianPA - Jan-17-2021, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 1,042 Mar-26-2024, 02:18 PM
Last Post: snippsat
  GroupBy - Sum = Error [datetime64 type does not support sum operations] BSDevo 4 3,727 Oct-27-2023, 07:22 PM
Last Post: BSDevo
  Type error in Cross_val_score Vicral 0 1,915 Jul-20-2021, 12:18 PM
Last Post: Vicral
  Error binding parameter 0 - probably unsupported type. illmattic 7 10,722 Jul-18-2020, 09:32 PM
Last Post: illmattic
  How to prepare a NumPy array which include float type array elements subhash 0 2,012 Mar-02-2020, 06:46 AM
Last Post: subhash
  TensorFlow get error - array with more than one element is ambiguous vokoyo 3 5,696 Nov-07-2019, 01:12 PM
Last Post: ThomasL
  Error Message: TypeError: unhashable type: 'set' twinpiques 4 19,586 May-22-2019, 02:31 PM
Last Post: twinpiques
  Error:unsupported operand type(s) for ** or pow(): 'list' and 'int' mcgrim 3 18,698 Mar-22-2019, 01:29 PM
Last Post: buran
  python odeint keeps giving me size of array error kiyoshi7 1 6,325 Nov-01-2018, 02:03 AM
Last Post: j.crater
  Type Error Confusion Oliver 4 14,756 Dec-06-2017, 03:20 PM
Last Post: Oliver

Forum Jump:

User Panel Messages

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