I am trying to calculate the inverse of a matrix via:
A = pd.read_csv("A_use.csv", header = None)
I = np.identity(len(A))
INV = np.linalg.inv(I - A)
However, the resulting array is full of np.nan
.
I don't understand why that's the case.
I've tried to replace all np.nan
values in A (although there shouldn't be any) via A[np.isnan(A)] = 0
but the problem persists.
Any suggestions?
The reason is an np.inf
value in at least column 293. The np.inf
value can be replaced via A[np.isinf(A)] = 0
. If np.inf
is replaced with zero, there are no np.nan
values in L.