Baking One Animation Curve Only

I want to bake one animation curve only (e.g. the one in Y Location channel) into keyframes with the Bake Action command:

Anim_Curves_Before_Baking

But all animation curves get baked:

Anim_Curves_After_Baking

I tried to bake one animation curve only with the following script, but it doesn’t work:

import bpy

context = bpy.context

ob = context.object
action = ob.animation_data.action

to_bake = ("location",
           )

fcs = (fc for fc in action.fcurves 
       if any(fc.data_path.endswith(p) for p in to_bake))

for fc in fcs:
    fc.convert_to_samples(1, 11)

Here’s the file (Blender v3.2.2):

Baking_One_Anim_Curve_Only.blend (803.2 KB)

How to bake one animation curve only with script?