Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Identify the columns that have a shared prefix.
  2. Specify the columns that should remain the same during the unpivot process using the id_vars parameter in pd.melt().
  3. Use the var_name parameter to specify the name of the new column that will contain the unpivoted variable names.
  4. Use the value_name parameter to specify the name of the new column that will contain the unpivoted values.
  5. Use the pd.melt() function to unpivot the specified columns.