1import pandas as pd
2
3# new data frame with split value columns
4data["Team"]= data["Team"].str.split(" ", n = 1, expand = True)
5
6# df display
7data
1import pandas as pd
2
3df = pd.DataFrame(["STD, City State",
4"33, Kolkata West Bengal",
5"44, Chennai Tamil Nadu",
6"40, Hyderabad Telengana",
7"80, Bangalore Karnataka"], columns=['row'])
8
9out = pd.DataFrame(df.row.str.split(' ',2).tolist(),columns=['STD','City','State'])
10out.drop(index=0,inplace=True)
1d = [pd.DataFrame(df[col].tolist()).add_prefix(col) for col in df.columns]
2df = pd.concat(d, axis=1)
3
4 id0 id1 id2 value0 value1 value2
50 10 10 NaN apple orange None
61 15 67 NaN banana orange None
72 12 34 45.0 apple banana orange
1df.Name.str.split(expand=True,)
2 0 1
30 Steve Smith
41 Joe Nadal
52 Roger Federer
6