March 2019
Beginner to intermediate
464 pages
10h 57m
English
Another attribute of a customer that would be interesting to see is the default rate, and how it differs between those who subscribed to a term deposit and those who did not. We are going to use the pivot_table function in the pandas library to analyze the default rates by conversions. Let's take a look at the following code:
default_by_conversion_df = pd.pivot_table( df, values='y', index='default', columns='conversion', aggfunc=len)
As you can see from this code, we are pivoting the DataFrame, df, by the y and default columns. By using len as the aggregation function, we can count how many customers fall under each cell of the pivot table. The results look as follows:
It is a bit difficult to compare how ...
Read now
Unlock full access