I am trying to apply own function into Pandas dataframe. Below you can see my function:
def ssc_function(gross_i1,ssc):
conditions = [
(ssc == 0 ),
(gross_i1 <= gross_i1*0.10)]
values = [0, gross_i1*0.5, gross_i1*0.15]
ssc_estimation = np.select(conditions, values)
return ssc_estimation
So next step is apply this function on separate column of this Pandas dataframe. Below you can see dataframe
data = {'name': ['Company1', 'Company2', 'Company3', 'Company4', 'Company5'],
'gross_i1': [0, 180395, 4543168, 7543168, 73],
'ssc': [4, 24, 31, 2, 3]}
df = pd.DataFrame(data, columns = ['name', 'gross_i1', 'ssc'])
df
and I try to apply this function to this dataframe with this line of code below
df['NewSSC'] = df.apply(ssc_function, axis=1)
But unfortunately I got error
TypeError: ssc_function() missing 1 required positional argument: 'ssc'
So can anybody help me hot solve this error ?