I have a dataframe like following:
col1 col2 col3 col4 col5... g1 x1 x2 x3 x4 g1 x5 x6 x7 x8 g2 y1 y2 y3 y4 g2