Easiest soln in Python for Beginners || Python3.
Intuition\nWhen analyzing data, especially time series or multi-dimensional data, creating a pivot table can help transform the data into a more readable and an
# Intuition\nWhen analyzing data, especially time series or multi-dimensional data, creating a pivot table can help transform the data into a more readable and analyzable format. In this case, we want to reorganize the data so that the rows represent months, the columns represent cities, and the cell values are the temperatures.\n\n# Approach\n1. Use the `pivot` method provided by pandas to reshape the DataFrame.\n2. Set the `index` parameter to \'month\', which will form the rows.\n3. Set the `columns` parameter to \'city\', which will form the columns.\n4. Set the `values` parameter to \'temperature\', which will populate the cells.\n5. Return the reshaped DataFrame.\n\n# Complexity\n- Time complexity:\n  The time complexity is approximately \\(O(n)\\), where \\(n\\) is the number of rows in the DataFrame. This is because each row is processed once to transform the DataFrame.\n\n- Space complexity:\n  The space complexity is approximately \\(O(n)\\), where \\(n\\) is the number of rows in the DataFrame. A new DataFrame is created with the reshaped data, which requires additional memory proportional to the size of the input DataFrame.\n\n# Code\n```python\nimport pandas as pd\n\ndef pivotTable(df: pd.DataFrame) -> pd.DataFrame:\n    return df.pivot(index=\'month\', columns=\'city\', values=\'temperature\')\n```\n\nThis function effectively pivots the DataFrame, transforming it into a format where the rows represent months, the columns represent cities, and the cell values are the temperatures. This is useful for easier comparison and analysis of temperature data across different cities and months.
['Pandas']