Move pivot to bottom or top of object/selection
If you need to move the origin to the bottom, you would need to move it down by the distance it is higher than the lowest point, so you could do: 

import bpy
from mathutils import Vector

o = bpy.context.object
d = o.data
m = o.matrix_world

lowest = min((m @ v.co)[2] for v in d.vertices)
difference = Vector((0,0,o.location.z - lowest))
local_difference = difference @ m
for v in d.vertices:
    v.co += local_difference
m.translation -= difference