A Father of three sons and a grandfather of 10 is in the last stages of his life. He wants to give his assets to his grandchildren (After allocating the asset, they can sell them, of course). He explained his lawyer following conditions(A strict grandfather).

  1. Oldest among his children get the priority
  2. Oldest grandchild of oldest son get the priority
  3. The Person selected using the above two conditions get the most liquid asset or the realization order (Details Given under the ‘DetailsAsset’ Dataframe).
  4. The above offer is based on how much money each grandchild has saved up to now a) Say one person has no savings, then no property is allocated to him/her. b) Say another person has savings of USD 100, grandfather will allocate up to USD 100 only. c) Any remaining security value goes to the next grandchild inline.

Expected outcome. Pandas/Python should calculate the remaining asset value after allocating to a person based above condition. I have used the following methods to solve the problems.

  1. Pandas groupby and cumsum menthod I could not get the intended result.

DataFrames used in the computation 1)

DetailsChildred = pd.DataFrame({'Grand_Children':['Josh','Amal','Shivan','More','Angel','Robot'],\
                           'Children':['Mr Deen','Mr Deen','Mr Deen','Mr Jecop','Mr Jecop','Mr Jecop'],\
DetailsAssets = pd.DataFrame({'Unique_Asset_id':['959CASH','960HOUSE','961SHARE','962CASH','963SHARE'],\

Please help since I am new to pandas and python i need help....

New contributor
user11953618 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    $\begingroup$ This looks like a question for school or for some exam. If you're new to pandas and python, I suggest learning pandas pandas.pydata.org and python learnpython.org. This site isn't intended to answer these types of questions for you. $\endgroup$ – fswings Sep 13 at 0:14