Question: I have a column of names that are in different languages and are entered in different formats. It appears that the English and Mandarin names have "," as a delimiter. The korean names have "." as a delimiter while the Japanese names have both "," and "/" as a delimiter. Am hoping to be able to obtain the New\_Name column

```
Name_old                                 Language              New_Name
Phillipe, Mr Johnson                     English               Mr Johnson Phillipe           

李, Mr 永                                 Mandarin              Mr 永 李

김두한.Kim Do Han                         Korean                Kim Do Han

Amori, Shinji/ あもりさせる / 由紀         Japanese              Shinji Amori

```

I have tried the following code but it only works for the English and Mandarin names. Am thinking i might have to filter the rows based on the language column and then string split. Appreciate any form of help, thank you. 

```
splitname = df1["Name_old"].str.split(",", n = 1, expand = True)  

# create first name column based on values after comma in Name_old column  
df1["First_Name"]= splitname[1]  

# create first name column based on values before comma in Name_old column 
df1["Last_Name"]= splitname[0]

#concatenate the first name and last name
df1['New_Name'] = df1['First_Name'] +' '+ df1['Last_Name']

```

Answer: 
One way is to use `np.select` with conditions base on your `Language`:

```
d = {"Name":["Phillipe, Mr Johnson","李, Mr 永","김두한.Kim Do Han","Amori, Shinji/ あもりさせる / 由紀"],
     "Language":["English","Mandarin","Korean","Japanese"]}

df = pd.DataFrame(d)

df["new"] = np.select([df["Language"].isin(["English", "Mandarin"]),
                       df["Language"].eq("Korean")],
                     [df["Name"].str.split(",", n = 1).str[::-1].str.join(" "),
                      df["Name"].str.findall(r"[A-Za-z]+").str.join(" ")],
                     df["Name"].str.findall(r"[A-Za-z]+").str[::-1].str.join(" "))

print (df)

#
                         Name  Language                   new
0        Phillipe, Mr Johnson   English   Mr Johnson Phillipe
1                     李, Mr 永  Mandarin                Mr 永 李
2              김두한.Kim Do Han    Korean            Kim Do Han
3  Amori, Shinji/ あもりさせる / 由紀  Japanese          Shinji Amori

```
You can split your string using regular expression:

```
import re

test_str = 'a,b.c/d,e,f.g/hij.k'

print(re.split(r'[,\/.]', test_str))

```

`r'[,\/.]'` means string of any of the three: `,`, `/` or `.`
Output would be:

```
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'hij', 'k']

```

Complete example:

```
import re
import pandas as pd

test_str = 'abc,def'

df = pd.DataFrame({"old_name": [test_str]})

def split_name(name):
    split_name = re.split(r'[,\/.]', test_str)
    return split_name[0], split_name[1]

df['first_name'], df['last_name'] = zip(*df['old_name'].apply(split_name))

print(df)

```

Output:

```
  old_name first_name last_name
0  abc,def        abc       def

```