Animated chart over time, plotting second axis not segregating over time

I thought to make an animated population pyramid of the Canadian population, Colab Link

I got as far as making a working animation for just the males using this code:

# Working animated pyramid for males only

import plotly.express as px

fig = px.bar(males, 
             x="Males", 
             y="Age group", 
            #  color="Males",
             animation_frame="REF_DATE")

fig.show()

When I tried to modify it to include the female data, it ended up plotting all the female data across all the years:

import plotly.express as px

fig = px.bar(males, 
             x="Males", 
             y="Age group", 
            #  color="Males",
             animation_frame="REF_DATE")

fig.add_trace(gp.Bar(y= y_age, x = females.Females * -1, 
                     name = 'Female', 
                     orientation = 'h'))

fig.show()

I consulted this plotly community post which seems to be talking about the same issue:

But try as I might, I couldn’t figure out how to make my code conducive to it. Appreciate any help