'How to retain the index count of dataframe from 1?

import pandas as pd
test = {'name': ['mnop', 'abcd', 'ijkl', 'efgh'], 'value': ['dfdf', 'jkjhk', 'cndlkcn', 'njnck']}
df = pd.DataFrame(test)
print(df)

Above code prints data as below

name    value
0  mnop     dfdf
1  abcd    jkjhk
2  ijkl  cndlkcn
3  efgh    njnck

Now, I would like to sort it by name and index starting from 1 to 4 and then sequentially. I tried, print(df.sort_values(by=['name'])) but index retains it's original association as below:

name    value
1  abcd    jkjhk
3  efgh    njnck
2  ijkl  cndlkcn
0  mnop     dfdf

How can this be done?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source