I have a df column which contains
Phone number
12399422/930201021
5451354;546325642
789888744,656313214
123456654
I would like to separate it into two columns
Phone number1 Phone number2
12399422 930201021
5451354 546325642
789888744 656313214
123456654
I have tried to use apply,
df['TELEPHONE1'] = df['TELEPHONE'].str.split(',').str.get(0)
df['TELEPHONE2'] = df['TELEPHONE'].str.split(',').str.get(1)
df['TELEPHONE1'] = df['TELEPHONE'].str.split(';').str.get(0)
df['TELEPHONE2'] = df['TELEPHONE'].str.split(';').str.get(1)
df['TELEPHONE1'] = df['TELEPHONE'].str.split('/').str.get(0)
df['TELEPHONE2'] = df['TELEPHONE'].str.split('/').str.get(1)
but it can only split '/' Thank you for your help
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…