I have this in pandas and python:
text1 text2
0 sunny This is a sunny day
1 rainy day No this day is a rainy day
and I want to transform it to this:
text1 text2
0 sunny This is a day
1 rainy day No this day is a
Therefore, I want to remove some text from text2 based on text1 of the same row.
I did this:
df = df.apply(lambda x: x['text2'].str.replace(x['text1'], ''))
but I was getting an error:
AttributeError: ("'str' object has no attribute 'str'", 'occurred at index 0')
which maybe related to this: https://stackoverflow.com/a/53986135/9024698.
What is the most efficient way to do what I want to do?