import pandas as pd
import numpy as np
def ced(x):
return x+1, x+2, x+3
df = pd.DataFrame(data=[[1,2],[10,20]], columns=['a','b'])
df['x'], df['y'], df['z'] = df['a'].apply(lambda x: ced(x))
print(df)
error:
line 11, in df['x'], df['y'], df['z'] = df['a'].apply(lambda x: ced(x)) ValueError: not enough values to unpack (expected 3, got 2)
this thing works for
import pandas as pd
import numpy as np
def ced(x):
return x+1, x+2
df = pd.DataFrame(data=[[1,2],[10,20]], columns=['a','b'])
df['x'], df['y'] = df['a'].apply(lambda x: ced(x))
print(df)
output:
a b x y
0 1 2 2 11
1 10 20 3 12
I don't know what is the problem here.