3073. Reshape Data: Melt
My accepted Python solution to LeetCode problem 3073, Reshape Data: Melt, running in 304ms.
- Difficulty: Easy
- Python
- Runtime 304ms
- Memory 66.9MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 304ms, memory 66.9MB, accepted 2026-01-02.
import pandas as pd
def meltTable(report: pd.DataFrame) -> pd.DataFrame:
return report.melt(id_vars='product', var_name='quarter', value_name='sales')