Get startedGet started for free

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.

This exercise is part of the course

Credit Risk Modeling in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create the cross table for loan status, home ownership, and the max employment length
print(pd.____(cr_loan[____],cr_loan[____],
        values=cr_loan[____], aggfunc=____))
Edit and Run Code