How do you store multiple returns of a function in one DataFrame. Here is an example in MRE.
import pandas as pd
import numpy as np
def example(height):
weight = height * 2
wingspan = height * 0.8
return weight, wingspan
df = pd.DataFrame(np.array([80, 60, 70]),
columns=['height'])
Now if were doing this with a function that only returned one output I would do it like this.
def example_row(row):
return example(row.height)
df['weight'] = df.apply(example_row, axis=1)
But I'm not sure how to add two columns one for weight and one for wingspan. Thanks in advance.