I need to extract the values from a column in pandas df and save those values in a separate column. I need to grab the strings that follow a specific pattern. My data looks like this:
name
ADV | FashionWeek.ab
ADV | FashionWeek
ADV | ESPN.arb
ADV | ESPN.ob
ADV | ESPN
The desired output is:
name clean_name
ADV | FashionWeek.ab FashionWeek
ADV | FashionWeek FashionWeek
ADV | ESPN.arb ESPN
ADV | ESPN.ob ESPN
ADV | ESPN ESPN
So I have to grab everything that comes after ADV | and before .
I tried:
new_df["clean_name"] = df["name"].split('|')[1].lstrip().split('.')[0]
error: AttributeError: 'DataFrame' object has no attribute 'split'