How to create and assign a group to an fcurve with python script?
Both the fcurves themselves, and the action groups are part of the action object. You have to create new groups through the action and then assign that group to any fcurves you want inside it.

armature = bpy.context.scene.objects.active
anim_data = armature.animation_data
action = anim_data.action

# create a new group
group_1 = action.groups.new("group_1")

# assign the first three fcurves to the new group
for fcurve in anim_data.action.fcurves[:3]:
    fcurve.group = group