Set index on predefined order using reindex:
In [14]: df.reindex(["Z", "C", "A"])
Out[14]:
company Amazon Apple Yahoo
Z 0 0 150
C 173 0 0
A 0 130 0
However, Use the below line of code if it's alphabetical order sort_index(ascending=False)
In [12]: df.sort_index(ascending=False)
Out[12]:
company Amazon Apple Yahoo
name
Z 0 0 150
C 173 0 0
A 0 130 0
Like pointed below, you need to assign it to some variable
In [13]: df = df.sort_index(ascending=False)
If you want to learn Python programming language for Data Science then you can watch this complete video tutorial: