I hope to use sampleBy to get samples based on the distribution of a column. For example, within each prod_name group, I'd like to do a sampleBy based on colour column sampleBy("colour", fractions ={"blue":0.5, "yellow",0.1, green: 0.3} How can I combine and use these two methods together? Many thanks for your help!
prod_name | colour | value | code
-------------------------------
A | blue |100 | Y
A | blue |200. | N
A | blue. |300. | Y
A | blue. |400. | Y
A | yellow. |500. | N
B | green. |600 | Y
B | green. |650 | Y
B | blue. |700 | N
C | red. |800. | Y
C | blue |900. | N
C | green |1000 | N