Skip to content

Instantly share code, notes, and snippets.

@SamKChang
Last active April 27, 2020 09:09
Show Gist options
  • Save SamKChang/f8a27182a970304fbf32d16c6dfe39ba to your computer and use it in GitHub Desktop.
Save SamKChang/f8a27182a970304fbf32d16c6dfe39ba to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Car loan\n",
"\n",
"Let $r$ and $S$ be interest rate and borrowed amount. The total amount to be repaid after $n$ terms is $S(1 + r)^n$. Assume we return $x$ each term. Each returned amont with interest after $n$ terms are\n",
"$$\n",
"\\begin{array}{rcl}\n",
"\\mbox{first term} & = & x(1+r)^{n-1}, \\\\\n",
"\\mbox{second term} & = & x(1+r)^{n-2}, \\\\\n",
"\\mbox{third term} & = & x(1+r)^{n-3}, \\\\\n",
"\\vdots && \\vdots \\\\\n",
"\\mbox{last term} & = & x. \\\\\n",
"\\end{array}\n",
"$$\n",
"We have the total borrowed equals to the total repaied with interest\n",
"$$\n",
"S(1+r)^n = x + x(1+r) + \\cdots x(1+r)^{n-1}.\n",
"$$\n",
"Applying standard geometric serise trick\n",
"$$\n",
"\\begin{array}{rccc}\n",
"&(1+r)\\big(S(1+r)^n\\big) &=& (1+r)\\big(x + \\cdots x(1+r)^{n-1}\\big)\\\\\n",
"-) &S(1+r)^n &=& x + x(1+r) + \\cdots x(1+r)^{n-1} \\\\\n",
"\\hline\n",
"&S(1+r)^{n+1} - S(1+r)^n &=& x(1+r)^n - x\n",
"\\end{array}\n",
"$$\n",
"We have\n",
"$$\n",
"x = \\frac{S(1+r)^nr}{(1+r)^n - 1}\n",
"$$\n",
"\n",
"Note that the total payment is $nx < S(1+r)^n$ due to the interest from each term."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def monthly_payment(price, interest_rate=0.0202, down_payment=10000, end_payment=1000, years=4):\n",
" \"\"\"\n",
" https://towardsdatascience.com/the-cost-of-financing-a-new-car-car-loans-c00997f1aee\n",
" \"\"\"\n",
" S = price - down_payment - end_payment\n",
" r = interest_rate / 12.0\n",
" # Only the first month is excluded.\n",
" n = years * 12. - 1\n",
" numerator = S * (1 + r) ** n * r\n",
" denominator = (1 + r) ** n - 1\n",
" # End payment's interest is distributed evenly into each term.\n",
" end_payment_interest = end_payment * (1 + interest_rate) ** years - end_payment\n",
" x = np.round(numerator / denominator + (end_payment_interest / n), 2)\n",
" total = np.round(down_payment + end_payment + x * n, 2)\n",
" return x, total"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"data = []\n",
"for years in [2,4]:\n",
" for rate in [0.0202]:\n",
" for down_payment in [10000, 13181]:\n",
" for end_payment in [1000, 5000, 8000]:\n",
" config = {\n",
" \"price\": 26900,\n",
" \"years\": years,\n",
" \"interest_rate\": rate,\n",
" \"down_payment\": down_payment,\n",
" \"end_payment\": end_payment,\n",
" }\n",
" monthly, total = monthly_payment(**config)\n",
" row = [monthly, total, total - config[\"price\"], years, rate, down_payment, end_payment]\n",
" data.append(row)\n",
"df = pd.DataFrame(data)\n",
"df.columns = [\"monthly\", \"total\", \"diff\", \"years\", \"rate\", \"down_payment\", \"end_payment\"]"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"def highlight_greaterthan(s, monthly_max, diff_max):\n",
" monthly_over = pd.Series(data=False, index=s.index)\n",
" diff_over = pd.Series(data=False, index=s.index)\n",
" monthly_over[\"monthly\"] = s.loc[\"monthly\"] >= monthly_max\n",
" diff_over[\"diff\"] = s.loc[\"diff\"] >= diff_max\n",
" output = []\n",
" for v in monthly_over:\n",
" if monthly_over.any():\n",
" output.append(\"color: red\")\n",
" elif diff_over.any():\n",
" output.append(\"color: orange\")\n",
" else:\n",
" output.append(\"\")\n",
" return output"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<style type=\"text/css\" >\n",
" #T_88853e08_8819_11ea_90cd_af733f27751crow1_col0 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col1 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col2 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col3 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col4 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col5 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow1_col6 {\n",
" color: red;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow5_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow6_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow7_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow8_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow9_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow10_col6 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col0 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col1 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col2 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col3 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col4 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col5 {\n",
" color: orange;\n",
" } #T_88853e08_8819_11ea_90cd_af733f27751crow11_col6 {\n",
" color: orange;\n",
" }</style><table id=\"T_88853e08_8819_11ea_90cd_af733f27751c\" ><thead> <tr> <th class=\"blank level0\" ></th> <th class=\"col_heading level0 col0\" >monthly</th> <th class=\"col_heading level0 col1\" >total</th> <th class=\"col_heading level0 col2\" >diff</th> <th class=\"col_heading level0 col3\" >years</th> <th class=\"col_heading level0 col4\" >rate</th> <th class=\"col_heading level0 col5\" >down_payment</th> <th class=\"col_heading level0 col6\" >end_payment</th> </tr></thead><tbody>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row0\" class=\"row_heading level0 row0\" >3</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col0\" class=\"data row0 col0\" >566.010000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col1\" class=\"data row0 col1\" >27199.230000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col2\" class=\"data row0 col2\" >299.230000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col3\" class=\"data row0 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col4\" class=\"data row0 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col5\" class=\"data row0 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow0_col6\" class=\"data row0 col6\" >1000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row1\" class=\"row_heading level0 row1\" >0</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col0\" class=\"data row1 col0\" >707.130000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col1\" class=\"data row1 col1\" >27263.990000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col2\" class=\"data row1 col2\" >363.990000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col3\" class=\"data row1 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col4\" class=\"data row1 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col5\" class=\"data row1 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow1_col6\" class=\"data row1 col6\" >1000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row2\" class=\"row_heading level0 row2\" >4</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col0\" class=\"data row2 col0\" >395.660000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col1\" class=\"data row2 col1\" >27281.180000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col2\" class=\"data row2 col2\" >381.180000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col3\" class=\"data row2 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col4\" class=\"data row2 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col5\" class=\"data row2 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow2_col6\" class=\"data row2 col6\" >5000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row3\" class=\"row_heading level0 row3\" >5</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col0\" class=\"data row3 col0\" >267.900000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col1\" class=\"data row3 col1\" >27342.700000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col2\" class=\"data row3 col2\" >442.700000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col3\" class=\"data row3 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col4\" class=\"data row3 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col5\" class=\"data row3 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow3_col6\" class=\"data row3 col6\" >8000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row4\" class=\"row_heading level0 row4\" >1</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col0\" class=\"data row4 col0\" >536.780000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col1\" class=\"data row4 col1\" >27345.940000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col2\" class=\"data row4 col2\" >445.940000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col3\" class=\"data row4 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col4\" class=\"data row4 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col5\" class=\"data row4 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow4_col6\" class=\"data row4 col6\" >5000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row5\" class=\"row_heading level0 row5\" >2</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col0\" class=\"data row5 col0\" >409.020000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col1\" class=\"data row5 col1\" >27407.460000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col2\" class=\"data row5 col2\" >507.460000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col3\" class=\"data row5 col3\" >2</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col4\" class=\"data row5 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col5\" class=\"data row5 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow5_col6\" class=\"data row5 col6\" >8000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row6\" class=\"row_heading level0 row6\" >9</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col0\" class=\"data row6 col0\" >283.460000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col1\" class=\"data row6 col1\" >27503.620000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col2\" class=\"data row6 col2\" >603.620000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col3\" class=\"data row6 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col4\" class=\"data row6 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col5\" class=\"data row6 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow6_col6\" class=\"data row6 col6\" >1000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row7\" class=\"row_heading level0 row7\" >6</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col0\" class=\"data row7 col0\" >353.910000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col1\" class=\"data row7 col1\" >27633.770000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col2\" class=\"data row7 col2\" >733.770000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col3\" class=\"data row7 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col4\" class=\"data row7 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col5\" class=\"data row7 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow7_col6\" class=\"data row7 col6\" >1000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row8\" class=\"row_heading level0 row8\" >10</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col0\" class=\"data row8 col0\" >201.960000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col1\" class=\"data row8 col1\" >27673.120000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col2\" class=\"data row8 col2\" >773.120000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col3\" class=\"data row8 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col4\" class=\"data row8 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col5\" class=\"data row8 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow8_col6\" class=\"data row8 col6\" >5000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row9\" class=\"row_heading level0 row9\" >11</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col0\" class=\"data row9 col0\" >140.840000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col1\" class=\"data row9 col1\" >27800.480000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col2\" class=\"data row9 col2\" >900.480000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col3\" class=\"data row9 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col4\" class=\"data row9 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col5\" class=\"data row9 col5\" >13181</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow9_col6\" class=\"data row9 col6\" >8000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row10\" class=\"row_heading level0 row10\" >7</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col0\" class=\"data row10 col0\" >272.410000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col1\" class=\"data row10 col1\" >27803.270000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col2\" class=\"data row10 col2\" >903.270000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col3\" class=\"data row10 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col4\" class=\"data row10 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col5\" class=\"data row10 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow10_col6\" class=\"data row10 col6\" >5000</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_88853e08_8819_11ea_90cd_af733f27751clevel0_row11\" class=\"row_heading level0 row11\" >8</th>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col0\" class=\"data row11 col0\" >211.290000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col1\" class=\"data row11 col1\" >27930.630000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col2\" class=\"data row11 col2\" >1030.630000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col3\" class=\"data row11 col3\" >4</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col4\" class=\"data row11 col4\" >0.020200</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col5\" class=\"data row11 col5\" >10000</td>\n",
" <td id=\"T_88853e08_8819_11ea_90cd_af733f27751crow11_col6\" class=\"data row11 col6\" >8000</td>\n",
" </tr>\n",
" </tbody></table>"
],
"text/plain": [
"<pandas.io.formats.style.Styler at 0x7fb66b1a4f50>"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sort_values(\"diff\").style.apply(highlight_greaterthan, monthly_max=600, diff_max=500, axis=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment