The correct answer is C. sort_values().
The sort_values() method is used to sort a DataFrame by the values in one or more columns in ascending or descending order. The method takes two arguments: the column(s) to sort by and the order (ascending or descending).
For example, to sort a DataFrame by the values in the A
column in ascending order, you would use the following code:
df.sort_values('A', ascending=True)
To sort a DataFrame by the values in the A
and B
columns in descending order, you would use the following code:
df.sort_values(['A', 'B'], ascending=False)
The apply() method is used to apply a function to each row of a DataFrame. The pivot_table() method is used to create a pivot table from a DataFrame. The filter() method is used to filter rows from a DataFrame based on a condition.