How can I combine the Index in the python dataframe?

jaffry_x :

in the following, can I make a single index for all the entries with common index.

cric = pd.Series(['India', 'Pakistan', 'South Africa', 'England', 'New Zealand'], 
                 index = ['Cricket', 'Cricket', 'Cricket', 'Cricket', 'Cricket'])
ftbl = pd.Series(['England', 'South Africa', 'Australia', 'Netherlands', 'New Zealand'], 
                 index = ['Football', 'Football', 'Football', 'Football' , 'Football'])
hock = pd.Series(['India', 'Pakistan', 'South Korea', 'England', 'India', 'New Zealand'], 
                 index = ['Hockey', 'Hockey', 'Hockey', 'Hockey', 'Hockey', 'Hockey'])

all_countries_1 = cric.append(ftbl)
all_countries_1 = all_countries_1.append(ftbl)
all_countries_1 = all_countries_1.append(hock)
all_countries_1 = all_countries_1.to_frame()
all_countries_1.columns = ['Countries']
all_countries_1

Actual Data

I want the following as my out The Expected Output

Chris :

Is this what you are looking for?

# zip the first three chars of the index and the index together
z = list(zip(all_countries_1.index.str[:3], all_countries_1.index))
# create multi index
idx = pd.MultiIndex.from_tuples(z)
# assign index
all_countries_1.index = idx

                 Countries
Cri Cricket          India
    Cricket       Pakistan
    Cricket   South Africa
    Cricket        England
    Cricket    New Zealand
Foo Football       England
    Football  South Africa
    Football     Australia
    Football   Netherlands
    Football   New Zealand
    Football       England
    Football  South Africa
    Football     Australia
    Football   Netherlands
    Football   New Zealand
Hoc Hockey           India
    Hockey        Pakistan
    Hockey     South Korea
    Hockey         England
    Hockey           India
    Hockey     New Zealand

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=390941&siteId=1