Suppose that I have an array defined by:
data = np.array([('a1v1', 'a2v1', 'a3v1', 'a4v1', 'a5v1'),
('a1v1', 'a2v1', 'a3v1', 'a4v2', 'a5v1'),
('a1v3', 'a2v1', 'a3v1', 'a4v1', 'a5v2'),
('a1v2', 'a2v2', 'a3v1', 'a4v1', 'a5v2'),
('a1v2', 'a2v3', 'a3v2', 'a4v1', 'a5v2'),
('a1v2', 'a2v3', 'a3v2', 'a4v2', 'a5v1'),
('a1v3', 'a2v3', 'a3v2', 'a4v2', 'a5v2'),
('a1v1', 'a2v2', 'a3v1', 'a4v1', 'a5v1'),
('a1v1', 'a2v3', 'a3v2', 'a4v1', 'a5v2'),
('a1v2', 'a2v2', 'a3v2', 'a4v1', 'a5v2'),
('a1v1', 'a2v2', 'a3v2', 'a4v2', 'a5v2'),
('a1v3', 'a2v2', 'a3v1', 'a4v2', 'a5v2'),
('a1v3', 'a2v1', 'a3v2', 'a4v1', 'a5v2'),
('a1v2', 'a2v2', 'a3v1', 'a4v2', 'a5v1')],
dtype=[('a1', '|S4'), ('a2', '|S4'), ('a3', '|S4'),
('a4', '|S4'), ('a5', '|S4')])
How to create a function to list out data elements by row with conditions given in a list of tuples, r.
r = [('a1', 'a1v1'), ('a4', 'a4v1')]
I know that it can be done manually like this:
data[(data['a1']=='a1v1') & data['a4']=='a4v1']
What about removing rows from data that comply with the r.
data[(data['a1']!='a1v1') | data['a4']!='a4v1']
Thanks.