IniziaInizia gratis

Finding outliers with cross tables

Now you need to find and remove outliers you suspect might be in the data. For this exercise, you can use cross tables and aggregate functions.

Have a look at the person_emp_length column. You've used the aggfunc = 'mean' argument to see the average of a numeric column before, but to detect outliers you can use other functions like min and max.

It may not be possible for a person to have an employment length of less than 0 or greater than 60. You can use cross tables to check the data and see if there are any instances of this!

The data set cr_loan has been loaded in the workspace.

Questo esercizio fa parte del corso

Credit Risk Modeling in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Create the cross table for loan status, home ownership, and the max employment length
print(pd.____(cr_loan[____],cr_loan[____],
        values=cr_loan[____], aggfunc=____))
Modifica ed esegui il codice