Complete the code to sort the DataFrame by the 'age' column in ascending order.
sorted_df = df.sort_values(by=[1])The sort_values() function sorts the DataFrame by the column name given in the by parameter. Here, we want to sort by the 'age' column.
Complete the code to sort the DataFrame by the 'score' column in descending order.
sorted_df = df.sort_values(by='score', ascending=[1])
Setting ascending=False sorts the DataFrame in descending order.
Fix the error in the code to correctly sort the DataFrame by the 'height' column.
sorted_df = df.sort_values(by=[1])The by parameter requires the column name as a string, so it must be in quotes.
Fill both blanks to create a dictionary comprehension that maps each word to its length, but only for words longer than 4 characters.
{word: [1] for word in words if [2]word.length() which is not valid in Python.The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 4 using len(word) > 4.
Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its score, but only if the score is positive.
{ [1]: [2] for [3], [2] in data.items() if [2] > 0 }item instead of unpacking key and value.The comprehension maps the uppercase version of the key (k.upper()) to its value (v) for each key-value pair (k, v) in data.items(), filtering only positive values.