Suppose I have a DF as following:
+-------+----------+ | value| group| +-------+----------+ | A| X| | A| X| | A| X| |