I am trying to figure out how to create a function to trigger inner nested function in order to create my desired output. I wish to output a new dataframe with new columns b