0

Pandas dataframe how to group by individual values in Features array?

Input:
Features || Product

[ fair, soft_skin, has_beard, fat]  || product01

[ soft_skin, dark, slim, has_beard ] || product02

[ soft_skin, dark] || product03

[ has_beard, slim] || product04

[ dark, has_beard, thick_skin] || product05

Expected output:
Feature || Products

fair || [product01]

soft_skin || [ product01, product02, product03] 

has_beard || [product01, product02, product04, product05] 

fat || [product01]

dark || [ product02, product03, product05 ]
TEX
  • 1
  • 1
  • You should provide you datasets as python objects. If lists, you can `explode` as a first step, then aggregate as list in a second time, see the two duplicates. – mozway Mar 24 '22 at 10:37

0 Answers0