Tuesday, 10 September 2013

Converting two lists into a matrix

Converting two lists into a matrix

I'll try to be as clear as possible. First and foremost I will explain why
I want to transform two arrays into a matrix
To plot a portfolio vs an index I need a data structure like this
[[portfolio_value1, index_value1]
[portfolio_value2, index_value2]]
But I have the the data as two separate 1-D arrays:
portfolio = [portfolio_value1, portfolio_value2, ...]
index = [index_value1, index_value2, ...]
So how do I transform the second scenario into the first. I've tried
np.insert to add the second array to a test matrix I had in a python
shell, my problem was to transpose the first array into a single column
matrix.
I hope the question is clear enough, please let me know if it's now.
Thanks in advance.

No comments:

Post a Comment