I have a 2-dimensional numpy array that looks like this:
[[a b c] [d e f] [g h i]] I'd like to print it without any of the default notational fluff that typically comes with arrays; namely the [, ] and the spaces between the elements. Something like this:
abc def ghi Is it possible to do such a thing (without a trivial and possibly expensive Python loop, of course)?
I have looked at numpy.set_printoptions but it looks like it only sets presentational options for how elements are displayed, not the characters in between.
Edit: The elements in the array have a string representation that can be anything, including [, ] and whitespace. Minimal example of how to build such an array:
class custom(object): def __repr__(self): return 'a' a = numpy.empty((5, 5), custom) a.fill(custom()) print a
.that you want to get rid of, but might include others that you don't? I'm not sure I understand what you want to strip..after each number used as delimiter (or as decimal separator, not sure). Later, I edited my question to reflect that the data type of the array was not necessarily numerical, and forgot to change the delimiter accordingly. Edited again.[]: stackoverflow.com/questions/9360103/…