Complete the code to convert the DataFrame from wide to long format using pandas.
long_df = pd.melt(df, id_vars=['id'], value_vars=[1])
The value_vars parameter should list the columns to unpivot. Here, 'score1' and 'score2' are the columns to convert from wide to long format.
Complete the code to rename the variable and value columns after melting.
long_df = pd.melt(df, id_vars=['id'], value_vars=['score1', 'score2'], var_name=[1], value_name='score')
The var_name parameter sets the name of the new column that holds the original column names. Here, we rename it to 'test'.
Fix the error in the code to correctly convert wide to long format with multiple id_vars.
long_df = pd.melt(df, id_vars=[1], value_vars=['score1', 'score2'])
When multiple columns identify each row, list them all in id_vars. Here, both 'id' and 'age' are identifiers.
Fill both blanks to create a long DataFrame with custom variable and value column names.
long_df = pd.melt(df, id_vars=['id'], value_vars=['score1', 'score2'], var_name=[1], value_name=[2])
Set var_name to 'test' to name the variable column, and value_name to 'score' to name the values column.
Fill all three blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.
lengths = { [1] : [2] for [3] in words if len([3]) > 3 }The dictionary comprehension uses word as the key, len(word) as the value, and iterates over word in words.