column 1 2 3 4
A hot too hot school playground
B weather cold too cold jacket
C rain water dirt rain coat
As you can see, there are repeated strings in different columns. Like hot and too hot. Is there a way where I can keep the string with longer length and delete that specific cell which has the same string?
the output I would want is something like this:
Column 1 2 3 4
A too hot school playground
B weather too cold jacket
B water dirt rain coat
data['repeat'] = data[['1', '2','3','4']].apply(lambda x: x.str.contains('hot'))
This is the code I am working on but this too is only allows me to select a specific string, which is not good if I am working on a large dataset.