0

here is my code to add additional column into x_vals, but i keep getting this error:

x_vals = np.array([x[0:4] for x in iris.data])
np.concatenate([x_vals, np.array([x[0] for x in iris.data])],1)

ValueError: all the input arrays must have same number of dimensions

can anyone help me ?

user3483203
  • 50,081
  • 9
  • 65
  • 94
  • In place of `x[0]` try either `x[0:1]` or `x[0, None]`. – Paul Panzer Sep 18 '18 at 22:51
  • Did you check the shape of `x_vals` and of the thing you are trying to add to it? The first thing we do when we get `dimensions` errors is to check the shapes! – hpaulj Sep 19 '18 at 02:54
  • Possible duplicate of [How to add an extra column to a NumPy array](https://stackoverflow.com/questions/8486294/how-to-add-an-extra-column-to-a-numpy-array) – Joe Sep 19 '18 at 06:03
  • I like this solution: https://stackoverflow.com/a/18207544/7919597 – Joe Sep 19 '18 at 06:03

0 Answers0