I need to apply a function and have the returned list’s values inserted into columns in the (new) dataframe. That is, if I have this:
import pandas as pd
def fu(myArg):
return {"one":myArg,"two":20}
li = [10,20]
df = pd.DataFrame(li,columns=["myArg"])
i would like to apply the fu
function to each row of the dataframe so that the output is :
myArg one two
0 10 10 20
1 20 20 20
(sorry for the extra spaced there, added for display reasons).
How do I go about doing this, efficiently?