Python_Easy_Beats_100%
IntuitionApproachUse .pivoted(index='',columns='city',values='temperature')Complexity
Time complexity:
o(n)
Space complexity:
o(1)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
Use .pivoted(index='',columns='city',values='temperature')
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
o(n)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
o(1)
# Code
```pythondata []
import pandas as pd

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