I have a function as below. I want to apply it over a row of a dataframe and return 2 values and then copy those 2 values in 2 columns. My both approaches fail (last 2 lines)
data1 = [['Alex',10,5,0],['Bob',12,4,1],['Clarke',13,6,0],['brke',15,1,0]]
df5 = pd.DataFrame(data1,columns=['Name','Age','weight','class'],dtype=float)
#print (df)
def calculate_distance2(row):
return pd.Series([row['Age']+row['weight'],row['Age']-row['weight']])
df5.apply(calculate_distance2, axis=1)
df5[['distance0'],['d6']]= df5.apply(calculate_distance2, axis=1)
df5['distance0'],df5['d6']= df5.apply(calculate_distance2, axis=1)
df5