[LeetCode] Pandas / 2889. Reshape data: Pivot

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

문제 링크

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

 

 

문제

 

코드

import pandas as pd

def pivotTable(weather: pd.DataFrame) -> pd.DataFrame:
    return weather.pivot(index='month', columns='city', values='temperature')