Group number shows the number of electrons in the outer shell. Metals form positive ions by losing electrons, non-metals form negative ions by gaining electrons. Groups 1 and 2 are all metals, groups 7 and 8 are all non-metals, with a transition in between.