That’s my code:
array = np.array([[0,1,2],[3,4,5],[6,7,8]])
axis1_mean = np.mean(array,axis = 0)
print(axis1_mean)
That’s the output:
[3. 4. 5.]
I need the output separated by commas, is there an easy way to do so?
I found in the documentation of Numpy that the output should be separated by commas. Does anyone see what I’m missing?
>Solution :
You need to separate the CONTENT of your data from the REPRESENTATION of your data. Your data is a list of three floating point numbers. There are no commas, no brackets, and no decimal points in your data.
If you need to PRESENT your data in a specific way, then it is up to you to do that. What you’re seeing is the way numpy presents data by default. If you want commas, you have to add them:
print( "[" + (",".join(str(f) for f in axis1_mean)) + "]")