pandas || 2 lines, groupby and merge || T/S: 99% / 99%
\nimport pandas as pd\n\ndef sales_analysis(product: pd.DataFrame, \n                   sales: pd.DataFrame) -> pd.DataFrame:\n\n    df = sales.groupby([\'produ
```\nimport pandas as pd\n\ndef sales_analysis(product: pd.DataFrame, \n                   sales: pd.DataFrame) -> pd.DataFrame:\n\n    df = sales.groupby([\'product_id\'], as_index = False\n             ).agg(min=(\'sale_date\', \'min\'), max=(\'sale_date\', \'max\'))\n\n    return df[(df[\'min\'] >=\'2019-01-01\') &\n              (df[\'max\'] <=\'2019-03-31\')].merge(product).iloc[:,[0,3]]\n```\n[https://leetcode.com/problems/sales-analysis-iii/submissions/1079605385/](https://leetcode.com/problems/sales-analysis-iii/submissions/1079605385/)\n\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ `len(sales)`.
['Pandas']