Skip to content

2889. Reshape Data: Pivot 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import pandas as pd


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