Use:
np.concatenate([a, b])
The arrays you want to concatenate need to be passed in as a sequence, not as separate arguments.
From the NumPy documentation:
numpy.concatenate((a1, a2, ...), axis=0)Join a sequence of arrays together.
It was trying to interpret your b as the axis parameter, which is why it complained it couldn't convert it into a scalar.
Use:
np.concatenate([a, b])
The arrays you want to concatenate need to be passed in as a sequence, not as separate arguments.
From the NumPy documentation:
numpy.concatenate((a1, a2, ...), axis=0)Join a sequence of arrays together.
It was trying to interpret your b as the axis parameter, which is why it complained it couldn't convert it into a scalar.
There are several possibilities for concatenating 1D arrays, e.g.,
import numpy as np
np.r_[a, a]
np.stack([a, a]).reshape(-1)
np.hstack([a, a])
np.concatenate([a, a])
All those options are equally fast for large arrays; for small ones, concatenate has a slight edge:

The plot was created with perfplot:
import numpy
import perfplot
perfplot.show(
setup=lambda n: numpy.random.rand(n),
kernels=[
lambda a: numpy.r_[a, a],
lambda a: numpy.stack([a, a]).reshape(-1),
lambda a: numpy.hstack([a, a]),
lambda a: numpy.concatenate([a, a]),
],
labels=["r_", "stack+reshape", "hstack", "concatenate"],
n_range=[2 ** k for k in range(19)],
xlabel="len(a)",
)
I am trying to plot (using matplotlib) some data.
Using Numpy i have made a few sets of arrays with the mean of my data, and i now want to plot my means, but i can't seem to figure out how to plot data from multiple arrays in one plot, nor can i figure out how to combine my arrays, and have tried the np.concatenate function, but it ain't working.
help