Complete the code to sort the DataFrame by its index in ascending order.
df_sorted = df.[1](ascending=True)
The sort_index() method sorts the DataFrame by its index. Other options either sort by values or do not exist in pandas.
Complete the code to sort the DataFrame by its index in descending order.
df_sorted = df.sort_index([1]=False)
The ascending parameter controls the sort order. Setting it to False sorts in descending order.
Fix the error in the code to sort the DataFrame by index in place.
df.sort_index(inplace=[1])The inplace parameter expects a boolean value True or False, not a string or other types.
Fill both blanks to sort the DataFrame by index in descending order and keep the result in a new variable.
df_sorted = df.[1](ascending=[2])
Use sort_index to sort by index, and set ascending=False for descending order.
Fill all three blanks to sort the DataFrame by index in ascending order, modify the original DataFrame, and return None.
result = df.[1](ascending=[2], inplace=[3])
sort_index sorts by index, ascending=True sorts ascending, and inplace=True modifies the original DataFrame returning None.