Convert DataFrame string complex i to j python // “Cloning” row or column vectors

清風oo發表於2018-12-05

https://stackoverflow.com/questions/30808286/convert-dataframe-string-complex-i-to-j-python

https://stackoverflow.com/questions/1550130/cloning-row-or-column-vectors

If you have a string like this: complexStr = "0.015291+0.0075383i", you could do:

complexFloat = complex(complexStr[:-1] + 'j')


Use numpy.tile:

>>> tile(array([1,2,3]), (3, 1))
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])

or for repeating columns:

>>> tile(array([[1,2,3]]).transpose(), (1, 3))
array([[1, 1, 1],
       [2, 2, 2],
       [3, 3, 3]])

 

相關文章