Easy one liner solution
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this solution is to transform the DataFrame from a long format (wh
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this solution is to transform the DataFrame from a long format (where each row represents a city-month combination) to a wide format (where each row represents a month and each city is a separate column). This operation is known as "pivoting" in data manipulation.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse pivot_table() on the input DataFrame weather.\nSet \'month\' as the index (rows).\nSet \'city\' as the columns.\nSet \'temperature\' as the values.\nUse \'max\' as the aggregation function\n# Complexity\nTime complexity: O(n)\n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity is O(n), where n is the total number of data points. The pivot_table() operation is generally considered to be O(n) for DataFrames of this size.\n\nSpace complexity: O(m * c)\n\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(m * c), where m is the number of unique months and c is the number of unique cities. This is because the pivoted table will have dimensions based on these unique values.\n\n# Code\n```pythondata []\nimport pandas as pd\n\ndef pivotTable(weather: pd.DataFrame) -> pd.DataFrame:\n        return weather.pivot_table(index=\'month\', columns=\'city\', values=\'temperature\', aggfunc=\'max\')\n\n```
['Pandas']