I have a dataframe that contains groups and percentages
| Group | A % | B % | Target % |
| ----- | --- | --- | -------- |
| A | .05 | .85 | 1.0 |
| A | .07 | .75 | 1.0 |
| A | .08 | .95 | 1.0 |
| B | .03 | .80 | 1.0 |
| B | .05 | .83 | 1.0 |
| B | .04 | .85 | 1.0 |
I want to be able to iterate column A % by column Group and find an array of values from column B % that when summed with each value in column A% is less than or equal to column Target %.
| Group | A % | B % | Target % | SumArray |
| ----- | --- | --- | -------- | ------------ |
| A | .05 | .85 | 1.0 | [.85,.75,.95]|
| A | .07 | .75 | 1.0 | [.85,.75] |
| A | .08 | .95 | 1.0 | [.85,.75] |
| B | .03 | .80 | 1.0 | [.80,.83,.85]|
| B | .05 | .83 | 1.0 | [.80,.83,.85]|
| B | .04 | .85 | 1.0 | [.80,.83,.85]|
I'd like to be able to use PySpark for this problem. Any ideas how to approach this?