This is the dataset that I'm working on
Sr. No. Product Rate Offered
0 1 Beige Glossy 100
1 2 BLACK TEXTURE 100
2 3 New Black Matt 100
3 4 PP Euro Grey Satin 100
4 5 PP Light Grey S/g (AAH) 100
I want extract features out of the Product column
Like the PP in 4th and 5th row is Pure Polyester Chemistry
I was able to break the string with new = data["Product"].str.split(" ", n = 5, expand = True)
And I get some thing like this
0 1 2 3 4
0 Beige Glossy None None None
1 BLACK TEXTURE None None None
2 New Black Matt None None
3 PP Euro Grey Satin None
4 PP Light Grey S/g (AAH)
I also gave the names to these new columns with this new.columns =['First','Second','Third','Fourth','Fifth']
First Second Third Fourth Fifth
0 Beige Glossy None None None
1 BLACK TEXTURE None None None
So I want to make a new column like this.So I use
filter = new.First=='PP'
new.insert(5,"Chemistry","PP")
new.where(filter,inplace=True)
new
First Second Third Fourth Fifth Chemistry
0 NaN NaN NaN NaN NaN NaN
1 NaN NaN NaN NaN NaN NaN
2 NaN NaN NaN NaN NaN NaN
3 PP Euro Grey Satin None PP
4 PP Light Grey S/g (AAH) PP
This kills all the other rows which are not PP