predictions = [x6,x5,x4,x3,x2,x1]
predictions
Calling the above list yields the following arrays:
[array([782.36739152]),
array([783.31415872]),
array([726.90474426]),
array([772.08910103]),
array([728.79734162]),
array([753.67887657])]
Yet I would like to print or call just the numbers inside, no array or brackets around the numbers.
Using the function below cleanly saves just the numbers to CSV, but I DON'T want to save the numbers, I want to call them inside iPython:
np.savetxt("P:/Earnest/Old/R/OutputPython.csv", predictions, delimiter=",")
How can I achieve this?
解决方案
If you change predictions to numpy array then, you can use print(*predictions.flatten(), sep=', ').
You can try as following:
import numpy as np
predictions = np.array([np.array([782.36739152]),
np.array([783.31415872]),
np.array([726.90474426]),
np.array([772.08910103]),
np.array([728.79734162]),
np.array([753.67887657])])
print(*predictions.flatten(), sep=', ')
Output:
782.36739152, 783.31415872, 726.90474426, 772.08910103, 728.79734162, 753.67887657