I have a dataframe, which simply looks like this:
edges
id node_id ...
0 'AX' ['A', 'B']
1 'BX' ['B', 'C']
2 'CX' ['C', 'C']
The 'id' column has string elements, and the 'node_id' column has lists (with strings inside).
I would like to remove some elements from this pandas df, if their 'node_id' has 2 same string.
In above dataframe this would be the 2nd element since its 'node_id' has 'C' and 'C'.
To do that, I am using the following:
edges[edges['node_id'].apply(lambda x: x[0]) != edges['node_id'].apply(lambda x: x[1])]
However, since .apply() is not really time efficient, I am looking for a built-in pandas function. Is there any to achieve what I do?