I have a column A which is the subset of another column B in my dataframe. I want to split the data in the parent column B with A so I get the remaining of B in a new column C. I was trying the below piece using lambda. But the inner column is A which I mention as Series can't be converted into str.
df['C'] = df['B'].apply(lambda x: x.split(df['A'],1)[1])
Example DF:
B A
Ford F-Series pickup Ford
Toyota Camry Toyoto
Ford Taurus/Taurus X Ford
Needed Output Data column:
C
F-Series pickup
Camry
Taurus/Taurus X
Here as the df['A'] is a series, we need it as a data from each row to do the same. Is there any possibility to pass the column A data as string. Any help would be appreciated. Thanks.