In [1]:
import pandas as pd
In [2]:
s_org = pd.Series(['aaa@xxx.com', 'bbb@yyy.com', 'ccc@zzz.com', 'ddd'], index=['A', 'B', 'C', 'D'])
print(s_org)
In [3]:
df = s_org.str.extract('(.+)@(.+)\.(.+)', expand=True)
print(df)
In [4]:
df = s_org.str.extract('(.+)@(.+)\.(.+)', expand=False)
print(df)
In [5]:
df_single = s_org.str.extract('(\w+)', expand=True)
print(df_single)
print(type(df_single))
In [6]:
s = s_org.str.extract('(\w+)', expand=False)
print(s)
print(type(s))
In [7]:
df_name = s_org.str.extract('(?P<local>.*)@(?P<second_LD>.*)\.(?P<TLD>.*)', expand=True)
print(df_name)