0

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 ?

silent_hunter
  • 2,224
  • 1
  • 12
  • 30
  • 1
    I really don't follow what that function is supposed to do, but the error is clear; the function signature expects to arguments and you only pass the grouped df – roganjosh Jan 30 '22 at 11:42
  • I really don't understand what do you want to say. If you have some idea please write here. Thank you ! – silent_hunter Jan 30 '22 at 14:59

0 Answers0