My question is related to this question:
Merge dataframe with another dataframe created from apply function?
Here is my version of code:
col = ['State','Annual Salary']
dat = [['New York', 132826], ['New Hampshire',128704], ['California',127388], ['Vermont',121599], ['Idaho',120011]]
df = pd.DataFrame(dat, columns=col)
def get_taxes_from_api(state, annual_salary):
return pd.DataFrame({'State': [state, state],
'annual.fica.amount': [int(annual_salary * 0.067),
int(annual_salary * 1.067)],
'annual.federal.amount': [int(annual_salary * 0.3),
int(annual_salary * 1.3)],
'annual.state.amount': [int(annual_salary * 0.048),
int(annual_salary * 1.048)]})
How do I apply get_taxes_from_api to each row of df and combine the returned dataframes into on dataframe?
The only difference is that my function returns a multiple-row dataframe, not a 1-row dataframe. So the solution to that question above does not work for my situation. (And I don't have enought reputation to leave a comment there.)