Reputation: 1930
Suppose I have 2 pandas series, which I perceive as column vector in linear algebra x1
and x2
I want to do the operation x1 * x2^T
, which is a column vector multiply with a row vector to produce a matrix (pandas dataframe).
What is the best procedure for this?
Upvotes: 0
Views: 2031
Reputation: 396
You want to import numpy
and call:
pandas.DataFrame(numpy.outer(x1, x2))
Upvotes: 2
Reputation: 5913
Inside of pandas
, you can go back to data frames to do it, e.g.
x1.to_frame().dot(x2.to_frame().T)
Upvotes: 1