Prompt
Answer
Function Name: CustomerSegmentation
Purpose: This function generates a dynamic segmentation of customers based on their spending.
Parameters:
spending_table
: A table containing customer spending data, with columnsCustomerID
andSpending
.segment_labels
: A list of labels to assign to each segment. The number of labels should be one less than the number of segments.
Return Type: A table containing customer segmentation data, with columns CustomerID
, Spending
, and Segment
.
Exceptions: Throws an exception if the number of segment labels does not match the number of segments.
Description
This function takes a table spending_table
containing customer spending data, with columns CustomerID
and Spending
, and a list of segment_labels
to assign to each segment. It returns a table with columns CustomerID
, Spending
, and Segment
. The number of segment_labels
should be one less than the number of segments. If the number of segment labels does not match the number of segments, an exception is thrown.