Keyframe Bar Chart Animation Efficiently
Here's how I would write this script for a single object. You could use a "for loop" to iterate through all of your objects.

import bpy

scene = bpy.context.scene
obj = scene.objects['Cube']

y_locations = [
    10,
    13,
    22,
]

current_frame = 0
for y_location in y_locations:
    obj.location[1] = y_location
    obj.keyframe_insert(
        data_path="location", frame=current_frame)

    current_frame += 20