like below fixes the issue If you are using pandas, you can create a mask that you can use to index the dataframe, negating the mask with ~: code :
df = pd.DataFrame(np.arange(12).reshape(3, 4))
# 0 1 2 3
# 0 0 1 2 3
# 1 4 5 6 7
# 2 8 9 10 11
value = 2
df[~(df[2] == value)]
# 0 1 2 3
# 1 4 5 6 7
# 2 8 9 10 11
df[~(df == value).any(axis=1)]
# 0 1 2 3
# 1 4 5 6 7
# 2 8 9 10 11
x = np.arange(12).reshape(3, 4)
# array([[ 0, 1, 2, 3],
# [ 4, 5, 6, 7],
# [ 8, 9, 10, 11]])
x[~(x == value).any(axis=1)]
# array([[ 4, 5, 6, 7],
# [ 8, 9, 10, 11]])
y = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
[row for row in y if not any(x == value for x in row)]
# [[4, 5, 6, 7], [8, 9, 10, 11]]
Share :

Python multiplication Matrix with Matrix transpose with array
By : EmreG_01
Date : March 29 2020, 07:55 AM
hop of those help? I'm assuming you are using zip because other posts about how to transpose a list of lists in python recommend using this. This is not what you are using... you are using numpy, so you want to use the .T attribute which returns the transpose of your array. Additionally, dot is a numpy function, not a method of a nmpy array: code :
b = b  np.dot(np.dot(linalg.inv(np.dot(J.T, J)), J.T), r(b))

How can I create a matrix, or convert a 2D array into matrix in Python?
By : Diogo Santos Almeida
Date : March 29 2020, 07:55 AM
To fix this issue I wish to be able to extract a row or a column from a 2D array in Python such that it preserves the 2D shape and can be used for matrix multiplication. However, I cannot find in the documentation how can this best be done. For example, I can use , You could use np.matrix directly: code :
>>> a = np.zeros(shape=(6,6))
>>> ma = np.matrix(a)
>>> ma
matrix([[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.]])
>>> ma[0,:]
matrix([[ 0., 0., 0., 0., 0., 0.]])
>>> a[0,:][np.newaxis, :]
array([[ 0., 0., 0., 0., 0., 0.]])

delete every nth row or column in a matrix using Python
By : Sandeep
Date : March 29 2020, 07:55 AM
Hope this helps You can use np.delete giving the indices corresponding to every 8th row index. Let a be a 2D array or a matrix: code :
np.delete(a, list(range(0, a.shape[0], 8)), axis=0)
np.delete(a, list(range(0, a.shape[1], 8)), axis=1)

python: how shall I extract one column and delete this column for a matrix array?
By : Faccio Prove
Date : March 29 2020, 07:55 AM
I hope this helps you . One simple solution I can think of  xx = list(map(lambda x: x[1:], xx))

python: how to convert an array into a matrix? with error: AttributeError: 'matrix' object has no attribute 'adjugate'
By : Sam Vanderplaetsen
Date : September 29 2020, 04:00 AM
With these it helps You can just replace your a = np.matrix(a) with a = Matrix(a). It will do for you. code :
import numpy as np
from sympy import Matrix
# firt part
a = Matrix(([1,2,0],[0,1,2],[2,0,1]))
a.adjugate()
#second part
a = np.array([[1,2,0], [0,1,2], [2,0,1]])
a = Matrix(a)
a = a.adjugate() # here is my problem.

