using np.where to avoid returning null after division
\nimport pandas as pd\n\ndef average_selling_price(prices: pd.DataFrame, units_sold: pd.DataFrame) -> pd.DataFrame:\n    df = pd.merge(prices, units_sold, on=\'
```\nimport pandas as pd\n\ndef average_selling_price(prices: pd.DataFrame, units_sold: pd.DataFrame) -> pd.DataFrame:\n    df = pd.merge(prices, units_sold, on=\'product_id\', how=\'left\')\n    df = df[df.purchase_date.isna() | ((df.purchase_date >= df.start_date) & (df.purchase_date <= df.end_date))]\n    df[\'total_revenue\'] = df.units*df.price\n    df = df.groupby(\'product_id\').agg(total_revenue=(\'total_revenue\', \'sum\'), total_units_sold=(\'units\', \'sum\')).reset_index()\n    df[\'average_price\'] = np.where(df.total_units_sold != 0, round(df.total_revenue/df.total_units_sold,2), 0)\n    return df[[\'product_id\', \'average_price\']]\n```
['Pandas']