So I am working on this python code where I have imported a excel file in from my desktop. Currently in my code I am having problem with executing my lambda function. I am to use the lambda function in the apply() method for the data column(s) with outliers (i.e., z-scores > 3 or < -3), set the value for the outliers to null (i.e., np.nan), otherwise retain the original value. I have types the line of code 2 different ways with the same outcome. However when I check to see if my overall code used the lambda function it did not and I don't know how to get my code to use the function instead of just running lambda as no part of the overall code.
data.SalaryZScores.apply(lambda SalaryZScores:np.nan if SalaryZScores > 3 or SalaryZScores<-3 else SalaryZScores)
Or
data['Salary'] = data['Salary'].apply(lambda Salary: random.randrange(data['Salary'].min(), data['Salary'].max())if pd.isnull(Salary) else Salary)
Aucun commentaire:
Enregistrer un commentaire