I am very new to Python, so please do help me. I have a data frame as below:

and I want to unstack/pivot it to below:

I tried different methods, but I am not getting the desired result.
I first tried groupby with only 2 values for trial, but this doesn't work for what I want and it fills with NaN:
newdf = df.groupby(['ACCIDENT_NO', 'SEX'])['Age_Group'].value_counts().unstack()
I also tried pivot_table:
new_1 = new_df.pivot_table(index=['ACCIDENT_NO'], columns= [ 'SEX','Age_Group'], aggfunc=len, fill_value=0)
This at least fills the zero but here SEX becomes the main columns and the age groups are subdivided under it. I dont care about any subdivisions or anything ...I just want to unstack the categories as different columns as shown in the desired image above.