I am trying to create a new column in a table from another one, this new column is a categorization of time intervals. I created a function to calculate the time intervals from the other column. Below is the function and error:
def calc_interval(df):
if (enq2020.TEMPO_REL_ANOS[(enq2020['TEMPO_REL_ANOS']<=1)]):
return 'menos de um 1 ano'
elif (enq2020.TEMPO_REL_ANOS[(enq2020['TEMPO_REL_ANOS']>1) &(enq2020['TEMPO_REL_ANOS']<=2.5 )]):
return 'entre 1 e 2.5 anos '
elif (enq2020.TEMPO_REL_ANOS[(enq2020['TEMPO_REL_ANOS']>2.5) &(enq2020['TEMPO_REL_ANOS']<=5 )]):
return 'entre 2.5 e 5 anos '
elif( enq2020.TEMPO_REL_ANOS[(enq2020['TEMPO_REL_ANOS']>5) &(enq2020['TEMPO_REL_ANOS']<=10 )]):
return 'entre 5 e 10 anos'
elif enq2020.TEMPO_REL_ANOS[ (enq2020['TEMPO_REL_ANOS'])>10]:
return 'mais de 10 anos'
enq2020['INTERVAL_REL']=enq2020['TEMPO_REL_ANOS'].apply(calc_interval,axis=1)
TypeError: calc_interval() got an unexpected keyword argument 'axis'
Aucun commentaire:
Enregistrer un commentaire