Deleting all groups with python API
Delete all groups in blend file.

BlendDataGroups.remove(...)

import bpy

for g in bpy.data.groups:
    bpy.data.groups.remove(g)


remove all empty groups (no objects assigned) from blend file

empty_groups = [g for g in bpy.data.groups if not g.objects]
while empty_groups:
    bpy.data.groups.remove(empty_groups.pop())


Note: For my current version (2.79.4) there are some extra options all set to True by default to "force the issue" without having to unlink and unset users.

&gt;&gt;&gt; bpy.data.groups.remove(
remove()
BlendDataGroups.remove(group, do_unlink=True, do_id_user=True, do_ui_user=True)
Remove a group from the current blendfile


See also.

Proper way to remove unused linked Group data-blocks