I have a following dataframe.(Actual columns in the dataframe are more than 30)
ID col1 col2 col3 col4
1 a## b## HO HO
2 c## d23 c## HO
3 a## k## z## s#
4 c## b12 a12 c12
5 b## HO z## HO
I want to make a new dataframe filtering rows that have all the strings ending with '##' and if one of the cells in the row contains 'HO',I want to skip it and return a row if the rest of the columns contain string ending with ##
In the above case new dataframe would be like this:
ID col1 col2 col3 col4
1 a## b## HO HO
3 a## k## z## s#
5 b## HO z## HO
currently I am doing
m = np.logical_and.reduce([
[x.endswith('##') for x in df[c] ] for c in df.columns if x!='HO'] )
But df[m] is only giving one following row and not the other two
3 a## k## z##
How can I fix this?