Complete the code to calculate the percentage change of the 'sales' column in the DataFrame.
df['pct_change'] = df['sales'].[1]()
The pct_change() function calculates the percentage change between the current and prior element in the column.
Complete the code to calculate the percentage change with a period of 2 rows.
df['pct_change_2'] = df['revenue'].[1](periods=2)
Setting periods=2 in pct_change() calculates the percentage change compared to 2 rows before.
Fix the error in the code to correctly calculate percentage change of the 'price' column.
df['price_change'] = df['price'].[1](periods=1)
The correct function name is pct_change() with an underscore and plural 'periods' parameter.
Fill both blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.
{word: [1] for word in words if [2]The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its value only if the value is greater than 0.
{ [1]: [2] for k, v in data.items() if v [3] 0 }The key is the uppercase version of k using k.upper(). The value is v. The condition filters values greater than 0 using >.