I have a similar problem like this, but this answer couldn't solve my problem
Pandas: create two new columns in a dataframe with values calculated from a pre-existing column .
I have a function which takes two parameters and return two different values in float
Original dataframes are also in float
def FunctionName (a, b):
some calculations---
return x, y
I have df
and I want to use function FunctionName
so that I will have two new Series from those existing Series df['A], df['B]
df['A], df['B]
df['A_new'], df['B_new'] = df[['A'], df['B']].apply(FunctionName)
gives me an error
TypeError: unhashable type: 'list'
I also tried
df['A_new'], df['B_new'] = FunctionName ( df['A'], df['B'])
gives me an error
TypeError: cannot convert the series to <class 'float'>
I want to use return X values to df['A_new']
and Y values to df['B_new']
Can someone please tell, what i am missing here ?