Answers for "Sort index values with pandas"

0

Sort index values with pandas

import pandas as pd

# Sort index from outer to inner in ascending order
df = df.sort_index()

# Display DataFrame
print(df)
Posted by: Guest on April-29-2022
0

how to sort values by index pandas

df = pd.DataFrame([1, 2, 3, 4, 5], index=[100, 29, 234, 1, 150],
...                   columns=['A'])
>>> df.sort_index()
     A
1    4
29   2
100  1
150  5
234  3
Posted by: Guest on March-14-2022

Python Answers by Framework

Browse Popular Code Answers by Language