is there a more efficient way to split a column based on characters?

I have a column named 'email' and I want to create a new column named 'company' that will take strings after the '@' up until the first '.' .


0     [email protected]
1    [email protected]
2    [email protected]

I was able to figure out a way of doing it but it would take a couple of steps (lines of code)

🔴 No definitive solution yet

📌 Solution 1

use extract to capture the string b/w @ and period.

df['email'].str.extract(r'@(.*?)\.' )
0   company
1   company
2   company