bubble_df df[['enc_uclass''purchase_week''price','product_id']groupby(['purchase_week'enc_uclass']agg{'price':'mean''product_id':'count'reset_index(bubble_df rename(columns={'product_id':'total_transactions'},inplace=truefigure - dataframe aggregated on per week per user_class level figure - showcases the resultant dataframe nowlet' visualize this data using scatter plot the following snippet does the job for us bubble_df plot scatter( ='purchase_week' ='price'plt title('purchase week vs price 'plt show(