python - Pandas force matrix multiplication -
i force matrix multiplication "orientation" using python pandas, both between dataframes against dataframes, dataframes against series , series against series.
as example, tried following code:
t = pandas.series([1, 2]) print(t.t.dot(t))
which outputs: 5
but expect this:
[1 2 2 4]
pandas great, inability matrix multiplications way want frustrating, appreciated.
ps: know pandas tries implicitly use index find right way compute matrix product, seems behavior can't switched off!
here:
in [1]: import pandas in [2]: t = pandas.series([1, 2]) in [3]: np.outer(t, t) out[3]: array([[1, 2], [2, 4]])
Comments
Post a Comment