The code without adding the keyframe
>>> c=bpy.data.objects["Z Function"]
>>> for f in range(100):
... bpy.context.scene.frame_set(f)
... for v in c.data.vertices:
... v.co.z=np.sin((np.pi*f)*(v.co.x))+np.cos((np.pi*f)*(v.co.y))
... # add keyframe for mesh vertice here
I tried using ob.keyframe_insert(data_path="location",index=-1) but didnt work because it probably keyframes the objects location and not the vertex's
I read this thread and it looked a bit complex to me , is there no solution to keyframing mesh vertex without using fcurves ?
Another thread used shapekeys to deform , but when I try add shape keys I get the following error

>>> sk_basis = c.shape_key_add("Basis")
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
TypeError: Object.shape_key_add(): required parameter "name" to be a keyword argument!
name="Basis"– pevinkinel Oct 03 '20 at 16:33