Thank you for your reply!
That works well for matrices (where the transpose can be written as simply x.t().flatten())
However, I am dealing with ndarrays, so that a matrix transpose is not applicable.