salesanalyzer_mds.segment_revenue_share ======================================= .. py:module:: salesanalyzer_mds.segment_revenue_share Functions --------- .. autoapisummary:: salesanalyzer_mds.segment_revenue_share.segment_revenue_share Module Contents --------------- .. py:function:: segment_revenue_share(sales_data: pandas.DataFrame, price_col: str = 'UnitPrice', quantity_col: str = 'Quantity', price_thresholds: tuple = None) -> pandas.DataFrame Segments products into three categories—cheap, medium, and expensive— based on price and calculates their respective share in total revenue. Parameters: ----------- sales_data : pd.DataFrame DataFrame containing historical sales data. price_col : str Column containing product prices. Default is 'UnitPrice'. quantity_col : str Column containing quantities sold. Default is 'Quantity'. price_thresholds : tuple, optional User-defined price thresholds (cheap_threshold, expensive_threshold). If None, quantiles (0.33, 0.67) are used. Returns: -------- pd.DataFrame A DataFrame showing the total revenue share for each price segment: 'cheap', 'medium', 'expensive'. Raises: ------- ValueError: If the input DataFrame is empty or specified columns contain missing data. KeyError: If any of the specified columns are missing in the DataFrame. TypeError: If any of the columns contain invalid data types.