Pandas two solution
Intuition\nThe new version of pandas has a function pivot_longer(), which will give a similar melt() result, but this simulator uses the old version of pandas. 
# Intuition\nThe new version of pandas has a function ```pivot_longer()```, which will give a similar ```melt()``` result, but this simulator uses the old version of pandas. The code using ```pivot_longer()``` is below:\n\n```\nproducts.pivot_longer(cols=["store1", "store2", "store3"], \n                      names_to=["store", "price"])\n```\n\n\n\n# Runtime\n272 ms\nBeats 100.00% of users with Pandas\n\n\n# Code\n\n```\nimport pandas as pd\n\ndef rearrange_products_table(products: pd.DataFrame) -> pd.DataFrame:\n    products = pd.melt(products, id_vars=\'product_id\', var_name=\'store\', value_name=\'price\').dropna()\n    return products\n```
['Pandas']