[LeetCode] Pandas / 2890. Reshape data: Melt

2024. 7. 8. 15:08Coding/LeetCode-Pandas

문제 링크

https://leetcode.com/problems/reshape-data-melt/description/

 

문제

 

코드

import pandas as pd

def meltTable(report: pd.DataFrame) -> pd.DataFrame:
    return report.melt(id_vars=['product'], var_name='quarter', value_name='sales')