0

I have a json data for segments like following: {"Segment_definitions":[{"segmentName":"S1","definition":{"a1":[19.0,25.0],"a2":["Seg2"]}},{"segmentName":"S2","definition":{"a4":[true,false],"a3":[4,6],"a1":[-1.0,21.0]}}]}

This is the deciding json data for categorisation.

Consumer examples -

  1. {"a1":{"type":"Double","value":21.0},"a2":{"type":"string","value":"Seg1"},"a3":{"type":"Int","value":5},"a4":{"type":"Boolean":"value":false}}

  2. {"a1":{"type":"Double","value":2.0},"a2":{"type":"string","value":"Seg2"},"a3":{"type":"Int","value":-1},"a4":{"type":"Boolean":"value":true}}

I need to categorise these 2 consumers into S1 or S2 segments. The code needs to be scalable to add further segments in the future. How do i do that using json arrays expicitly?

I have tried converting to dataframe and tried to compare row by row but the code was too tedious.

2
  • What defines whether a customer is in each segment? Commented Sep 29, 2022 at 7:54
  • the json with "segment definitions" are the conditions that a consumer data needs to pass to be classified into that particular segment. I have given 2 consumer data as examples to test Commented Sep 29, 2022 at 10:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.