I am trying to remove rows from a dataframe where the first sequence of letters in the Ref
column are equal to the Product
column.
For example, for the input:
+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| DVX | DVX9251 |
+---------+---------------+
| CDV | 22CDV95 |
+---------+---------------+
| TV | TV12369 |
+---------+---------------+
| TV | 992TV15 |
+---------+---------------+
Desired output:
+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| CDV | 22CDV95 |
+---------+---------------+
| TV | 992TV15 |
+---------+---------------+
I have tried both of the following pieces of code but they are not working
df = df.loc[df['Provision Ref'].str[0:df['Product'].map(len)] != df['Product']]
df = df.loc[df['Provision Ref'].str[0:int(df['Product'].map(len))] != df['Product']]