I have a dataframe like this
df:
col1 col2
blue water bottle blue
red wine glass red
green cup green
I want make another column which will ignore the value of col2 from col1
for example the new column col3 will be:
water bottle
wine glass
green cup
I have tried this code:
df.apply(lambda x: x['col1'].replace(x['col2'], ''), axis=1)
But I am getting following error:
AttributeError: ("'NoneType' object has no attribute 'replace'", 'occurred at index 0')
How to do it ?

df["col3"] = df.apply(lambda x: x["col1"].replace(x["col2"], ""), axis=1)should work. My guess is you haveNonevalue somewhere. You could check withdf[df.col1.isnull()]