Super simple Pandas - Step-by-Step Explained
\nimport pandas as pd\n\ndef rearrange_products_table(products: pd.DataFrame) -> pd.DataFrame:\n    # set product_id as the index, preparing for stacking stores
```\nimport pandas as pd\n\ndef rearrange_products_table(products: pd.DataFrame) -> pd.DataFrame:\n    # set product_id as the index, preparing for stacking stores\n    products.set_index(\'product_id\', inplace=True)\n\n    # stack stores\n    products = products.stack(dropna=True).reset_index()\n\n    # rename columns\n    products.columns = [\'product_id\',\'store\',\'price\']\n    return pd.DataFrame(products)\n```
['Pandas']