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
- 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 301ms, memory 67.7MB, accepted 2026-01-02.
import pandas as pd
def pivotTable(weather: pd.DataFrame) -> pd.DataFrame:
return weather.pivot(index='month', columns='city', values='temperature')