LeetCode solutions

3072. Reshape Data: Pivot

My accepted Python solution to LeetCode problem 3072, Reshape Data: Pivot, running in 301ms.

  • Difficulty: Easy
  • Python
  • Runtime 301ms
  • Memory 67.7MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 301ms, memory 67.7MB, accepted 2026-01-02.

python
import pandas as pd

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

Source