Assuming a dataframe, df, using pandas in the size of n x m.
I would like to perfom linear algebra operation on df.
Until now, I was unable to find a way to perfom directly linear algebra on df. What i was able to find is how to convert df from pandas format to Numpy using:
A = DataFrame.as_matrix
then I can simpy do
linalg.inv(A)
Is there a direct way of performing linear operation in Scipy using pandas dataframe? for example:
linalg.inv(df)
The reason I would like to use the linear algebra operation from scipy instead of Numpy is based on:
In any case, SciPy contains more fully-featured versions of the linear algebra modules, as well as many other numerical algorithms. If you are doing scientific computing with python, you should probably install both NumPy and SciPy. Most new features belong in SciPy rather than NumPy.
pandasandscipyare built onnumpy. Mostscipycode assumes inputs are arrays, or can be converted to such.scipyinvconverts the input to anumpyarray (withnp.asarray). If a dataframe works in a scipy function it's because it can be converted to an array.