Easy to understand Pandas solution
Approach\nWe first get all first years of each product, using groupby and transform.\nThen we get a subset of all sales data where products were sold in their f
# Approach\nWe first get all first years of each product, using groupby and transform.\nThen we get a subset of all sales data where products were sold in their first year\nLastly, we return the required columns\n# Code\n```pythondata []\nimport pandas as pd\n\ndef sales_analysis(sales: pd.DataFrame, product: pd.DataFrame) -> pd.DataFrame:\n    sales[\'first_year\'] = sales.groupby(\'product_id\')[[\'year\']].transform(\'min\')\n\n    sales = sales[sales.first_year == sales.year]\n\n    return sales[[\'product_id\', \'first_year\', \'quantity\', \'price\']]\n```
['Database', 'Python3', 'Pandas']