0
>>> Ne['State_1_spe_sum'].shape
(3, 1)
>>> Ne['State_1_inc'].shape
(63, 1)
>>> np.vstack((Ne['State_1_spe_sum'], Ne['State_1_inc']))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-58-2c1ac75279f6> in <module>
----> 1 np.vstack((Ne['State_1_spe_sum'], Ne['State_1_inc']))

<__array_function__ internals> in vstack(*args, **kwargs)

~\anaconda3\lib\site-packages\numpy\core\shape_base.py in vstack(tup)
    281     if not isinstance(arrs, list):
    282         arrs = [arrs]
--> 283     return _nx.concatenate(arrs, 0)
    284 
    285 

<__array_function__ internals> in concatenate(*args, **kwargs)

TypeError: invalid type promotion

It is to my understanding that stacking arrays using numpy vstack requires the arrays to have the same dimensions and column (for vstacking). I met the requirements, but why do I keep getting this error? I tried doing the np.concatenate but it's giving me the same error. Can anybody help me understand what's going on?

vlaaaaaddd
  • 19
  • 5

1 Answers1

0

There's not enough information in your question to answer.

Taking what you've provided so far:

import numpy as np

a = np.array([[1]] * 3, dtype='<f8')
print(a.shape)
b = np.array([[1]] * 61, dtype='<f8')
print(b.shape)

c = np.vstack((a, b))
print(c.shape)

Result:

(3, 1)
(61, 1)
(64, 1)

You'll need to provide more information on the type and content of your arrays, or share example code that shows how you construct them, to allow us to reproduce the error.

Grismar
  • 27,561
  • 4
  • 31
  • 54
  • Yeah sorry about that. Turns out my arrays don't have matching dtypes. I was able to fix my problem now. Thank you. – vlaaaaaddd Nov 18 '21 at 06:53
  • That's alright - you should either post an answer yourself and accept it, accept this answer if you feel it answers it (although I don't think so), or remove the question if you feel it was just a mistake. – Grismar Nov 18 '21 at 07:00