{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# import useful packages\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import matplotlib.patheffects as pe\n", "import seaborn as sns\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "\n", "# Set plots to be embedded inline\n", "%matplotlib inline\n", "\n", "# Set better dpi displays on larger screen resolutions\n", "%config InlineBackend.figure_format = 'retina'\n", "\n", "# Set default plot styles and color palette\n", "plt.style.use('default')\n", "color_list = sns.color_palette('tab20c')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Load the dataframe for analysis\n", "df = pd.read_csv('./prosper_loan_clean.csv')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# -- Convert prosper rating and income range to ordered category types\n", "\n", "# Store the correct variable orders in a dictionary\n", "order_dict = {'ProsperRating': ['HR', 'E', 'D', 'C', 'B', 'A', 'AA'],\n", " 'IncomeRange': ['$0', '$1-24,999', '$25,000-49,999', \n", " '$50,000-74,999', '$75,000-99,999', '$100,000+']}\n", "\n", "# Assign each column to the proper order\n", "for key, value in order_dict.items():\n", " correct_order = pd.api.types.CategoricalDtype(categories=value, ordered=True)\n", " df[key] = df[key].astype(correct_order)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# How Prosper Rating may Influence Loan Favorability" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
" ], "text/plain": [ "