evenly space keyframes in dopesheet
Helper Script

For each fcurve in the context object's action, space keyframes evenly based on start, end frame and how many keyframes.

import bpy
context = bpy.context
ob = context.object
ad = ob.animation_data
action = ad.action if ad else None

if action:

    fs, fend = action.frame_range
    flength = fend - fs            
    for fc in action.fcurves:            
        N = len(fc.keyframe_points) 
        if N &lt; 2:
            continue
        df = flength / (N - 1)

        for i, kfp in enumerate(fc.keyframe_points):
            kfp.co.x = fs + i * df