I have two datasets with a common ID but not the same level of granularity, and i need to join both files and spread the amount i have in df2 over several rows in df1 having the same common ID but have are split into contracts ....
I know that i need to 1st count the contracts i have by ID and then find a way to divide the amount proportionnaly
In general it will be easier to get help with a minimal reproducible example, or reprex. Sometimes making one will even show you where the problem is, which is always a great feeling!
I tried to make some fake data to reproduce your problem. If this not an accurate representation, please post some more detail about your problem: