Skip to content

Commit abdd11d

Browse files
committed
more formatting
1 parent d01c817 commit abdd11d

2 files changed

Lines changed: 121 additions & 82 deletions

File tree

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
Accident Half-Year,Calendar Half-Year,Closed Claim Counts,Reported Claim Counts,Reported Claims,Reported Severity,Paid Claims
2-
2003-07,2003-07,2547,3556,14234668,4003,
3-
2003-07,2004-01,3262,3314,14959396,4514,
4-
2003-07,2004-07,3287,3301,14920520,4520,
5-
2003-07,2005-01,3291,3299,14911480,4520,
6-
2003-07,2005-07,3292,3295,14926350,4530,
7-
2003-07,2006-01,3292,3294,14862528,4512,
8-
2003-07,2006-07,3292,3293,14861309,4513,
9-
2003-07,2007-01,3292,3293,14854723,4511,
10-
2003-07,2007-07,3292,3293,14851430,4510,
11-
2003-07,2008-01,3292,3292,14846920,4510,14846000
12-
2004-01,2004-01,2791,3492,14547672,4166,
13-
2004-01,2004-07,3217,3262,14672476,4498,
14-
2004-01,2005-01,3240,3250,14644500,4506,
15-
2004-01,2005-07,3242,3247,14627735,4505,
16-
2004-01,2006-01,3243,3247,14621241,4503,
17-
2004-01,2006-07,3243,3245,14608990,4502,
18-
2004-01,2007-01,3243,3245,14608990,4502,
19-
2004-01,2007-07,3243,3244,14610976,4504,
20-
2004-01,2008-01,3242,3243,14616201,4507,14614000
21-
2004-07,2004-07,2099,2980,12128600,4070,
22-
2004-07,2005-01,2677,2712,12575544,4637,
23-
2004-07,2005-07,2695,2704,12541152,4638,
24-
2004-07,2006-01,2697,2702,12531876,4638,
25-
2004-07,2006-07,2697,2700,12522600,4683,
26-
2004-07,2007-01,2698,2700,12522600,4638,
27-
2004-07,2007-07,2698,2699,12509865,4635,
28-
2004-07,2008-01,2698,2699,12501768,4632,12502000
29-
2005-01,2005-01,2370,2896,11980752,4137,
30-
2005-01,2005-07,2735,2768,11921776,4307,
31-
2005-01,2006-01,2751,2761,11883344,4304,
32-
2005-01,2006-07,2754,2758,11862158,4301,
33-
2005-01,2007-01,2755,2758,11853884,4298,
34-
2005-01,2007-07,2755,2758,11842852,4294,
35-
2005-01,2008-01,2756,2757,11841315,4295,11840000
36-
2005-07,2005-07,1966,2814,11284140,4010,
37-
2005-07,2006-01,2609,2650,11842850,4469,
38-
2005-07,2006-07,2630,2640,11806080,4472,
39-
2005-07,2007-01,2634,2639,11788413,4467,
40-
2005-07,2007-07,2634,2638,11770756,4462,
41-
2005-07,2008-01,2634,2636,11769740,4465,11765000
42-
2006-01,2006-01,2261,2808,11945232,4254,
43-
2006-01,2006-07,2671,2712,11856864,4372,
44-
2006-01,2007-01,2694,2704,11819184,4371,
45-
2006-01,2007-07,2696,2701,11773659,4359,
46-
2006-01,2008-01,2697,2700,11761200,4356,11755000
47-
2006-07,2006-07,1949,2799,12503133,4467,
48-
2006-07,2007-01,2637,2675,12762425,4771,
49-
2006-07,2007-07,2659,2670,12706530,4759,
50-
2006-07,2008-01,2662,2668,12697012,4759,12679000
51-
2007-01,2007-01,2059,2578,11662872,4524,
52-
2007-01,2007-07,2496,2533,11522617,4549,
53-
2007-01,2008-01,2520,2529,11491776,4544,11406000
54-
2007-07,2007-07,2083,2791,12646021,4531,
55-
2007-07,2008-01,2732,2778,12853806,4627,12648000
56-
2008-01,2008-01,2533,3139,14072137,4483,11833000
1+
Accident Half-Year,Calendar Half-Year,Closed Claim Counts,Reported Claim Counts,Reported Claims,Reported Severity,Paid Claims
2+
2003-07,2003-07,2547,3556,14234668,4003,
3+
2003-07,2004-01,3262,3314,14959396,4514,
4+
2003-07,2004-07,3287,3301,14920520,4520,
5+
2003-07,2005-01,3291,3299,14911480,4520,
6+
2003-07,2005-07,3292,3295,14926350,4530,
7+
2003-07,2006-01,3292,3294,14862528,4512,
8+
2003-07,2006-07,3292,3293,14861309,4513,
9+
2003-07,2007-01,3292,3293,14854723,4511,
10+
2003-07,2007-07,3292,3293,14851430,4510,
11+
2003-07,2008-01,3292,3292,14846920,4510,14846000
12+
2004-01,2004-01,2791,3492,14547672,4166,
13+
2004-01,2004-07,3217,3262,14672476,4498,
14+
2004-01,2005-01,3240,3250,14644500,4506,
15+
2004-01,2005-07,3242,3247,14627735,4505,
16+
2004-01,2006-01,3243,3247,14621241,4503,
17+
2004-01,2006-07,3243,3245,14608990,4502,
18+
2004-01,2007-01,3243,3245,14608990,4502,
19+
2004-01,2007-07,3243,3244,14610976,4504,
20+
2004-01,2008-01,3242,3243,14616201,4507,14614000
21+
2004-07,2004-07,2099,2980,12128600,4070,
22+
2004-07,2005-01,2677,2712,12575544,4637,
23+
2004-07,2005-07,2695,2704,12541152,4638,
24+
2004-07,2006-01,2697,2702,12531876,4638,
25+
2004-07,2006-07,2697,2700,12522600,4638,
26+
2004-07,2007-01,2698,2700,12522600,4638,
27+
2004-07,2007-07,2698,2699,12509865,4635,
28+
2004-07,2008-01,2698,2699,12501768,4632,12502000
29+
2005-01,2005-01,2370,2896,11980752,4137,
30+
2005-01,2005-07,2735,2768,11921776,4307,
31+
2005-01,2006-01,2751,2761,11883344,4304,
32+
2005-01,2006-07,2754,2758,11862158,4301,
33+
2005-01,2007-01,2755,2758,11853884,4298,
34+
2005-01,2007-07,2755,2758,11842852,4294,
35+
2005-01,2008-01,2756,2757,11841315,4295,11840000
36+
2005-07,2005-07,1966,2814,11284140,4010,
37+
2005-07,2006-01,2609,2650,11842850,4469,
38+
2005-07,2006-07,2630,2640,11806080,4472,
39+
2005-07,2007-01,2634,2639,11788413,4467,
40+
2005-07,2007-07,2634,2638,11770756,4462,
41+
2005-07,2008-01,2634,2636,11769740,4465,11765000
42+
2006-01,2006-01,2261,2808,11945232,4254,
43+
2006-01,2006-07,2671,2712,11856864,4372,
44+
2006-01,2007-01,2694,2704,11819184,4371,
45+
2006-01,2007-07,2696,2701,11773659,4359,
46+
2006-01,2008-01,2697,2700,11761200,4356,11755000
47+
2006-07,2006-07,1949,2799,12503133,4467,
48+
2006-07,2007-01,2637,2675,12762425,4771,
49+
2006-07,2007-07,2659,2670,12706530,4759,
50+
2006-07,2008-01,2662,2668,12697012,4759,12679000
51+
2007-01,2007-01,2059,2578,11662872,4524,
52+
2007-01,2007-07,2496,2533,11522617,4549,
53+
2007-01,2008-01,2520,2529,11491776,4544,11406000
54+
2007-07,2007-07,2083,2791,12646021,4531,
55+
2007-07,2008-01,2732,2778,12853806,4627,12648000
56+
2008-01,2008-01,2533,3139,14072137,4483,11833000

docs/friedland/chapter_11.ipynb

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
" exh_df:pd.DataFrame,\n",
4848
" value_cols: list[str] = [],\n",
4949
" factor_cols: list[str] = [],\n",
50-
" other_formats: dict = {}\n",
50+
" other_formats: dict = {},\n",
51+
" date_format: str = \"{:%Y}\"\n",
5152
"):\n",
5253
" return exh_df \\\n",
5354
" .reset_index() \\\n",
@@ -56,7 +57,7 @@
5657
" .hide(axis='index') \\\n",
5758
" .set_properties(**{\"text-align\":\"right\"}) \\\n",
5859
" .format({\n",
59-
" 'Accident Year':\"{:%Y}\",\n",
60+
" 'Accident Year':date_format,\n",
6061
" **{x:\"{:,.0f}\" for x in value_cols},\n",
6162
" **{x:\"{:,.3f}\" for x in factor_cols},\n",
6263
" **other_formats\n",
@@ -245,7 +246,7 @@
245246
"print('PART 2 - Age-to-Age Factors')\n",
246247
"nb_display(e1_tri['Closed Claim Counts'].age_to_age.round(3))\n",
247248
"print('PART 3 - Average Age-to-Age Factor')\n",
248-
"nb_display(combine_ldf(e1_ccc_devs).round(3).to_frame())\n",
249+
"nb_display(combine_ldf(e1_ccc_devs).round(3).to_frame().rename_axis(\"\"))\n",
249250
"print('PART 4 - Selected Age-to-Age Factors')\n",
250251
"print('Selected')\n",
251252
"nb_display(e1_ccc_selected.ldf_)\n",
@@ -294,7 +295,7 @@
294295
"print('PART 2 - Age-to-Age Factors')\n",
295296
"nb_display(e1_tri['Reported Claim Counts'].age_to_age.round(3))\n",
296297
"print('PART 3 - Average Age-to-Age Factor')\n",
297-
"nb_display(combine_ldf(e1_rcc_devs).round(3).to_frame())\n",
298+
"nb_display(combine_ldf(e1_rcc_devs).round(3).to_frame().rename_axis(\"\"))\n",
298299
"print('PART 4 - Selected Age-to-Age Factors')\n",
299300
"print('Selected')\n",
300301
"nb_display(e1_rcc_selected.ldf_)\n",
@@ -362,7 +363,9 @@
362363
" [\n",
363364
" 'Closed CDF',\n",
364365
" 'Reported CDF',\n",
365-
" ]\n",
366+
" ],\n",
367+
" {},\n",
368+
" \"{:%Y%m}\"\n",
366369
") "
367370
]
368371
},
@@ -480,7 +483,7 @@
480483
"print('PART 2 - Age-to-Age Factors')\n",
481484
"nb_display(e1_rsev.age_to_age.round(3))\n",
482485
"print('PART 3 - Average Age-to-Age Factors')\n",
483-
"nb_display(combine_ldf(e1_rsev_devs).round(3).to_frame())\n",
486+
"nb_display(combine_ldf(e1_rsev_devs).round(3).to_frame().rename_axis(\"\"))\n",
484487
"print('PART 4 - Selected Age-to-Age Factors')\n",
485488
"nb_display(e1_rsev_selected.ldf_)\n",
486489
"print('CDF to Ultimate')\n",
@@ -539,7 +542,9 @@
539542
" 'Selected Ult CC',\n",
540543
" 'Ult Claims',\n",
541544
" ],\n",
542-
" ['CDF']\n",
545+
" ['CDF'],\n",
546+
" {},\n",
547+
" \"{:%Y%m}\"\n",
543548
")"
544549
]
545550
},
@@ -578,7 +583,7 @@
578583
"outputs": [],
579584
"source": [
580585
"e1_s8 = summary_exh(e1_tri['Reported Claims']/1000,e1_tri['Paid Claims']/1000,e1_ult)\n",
581-
"format_exh(e1_s8,e1_s8.columns)"
586+
"format_exh(e1_s8,e1_s8.columns,[],{},\"{:%Y%m}\")"
582587
]
583588
},
584589
{
@@ -750,7 +755,7 @@
750755
"print('PART 2 - Age-to-Age Factors')\n",
751756
"nb_display(e2_tri['Closed Claim Counts'].age_to_age.round(3))\n",
752757
"print('PART 3 - Average Age-to-Age Factor')\n",
753-
"nb_display(combine_ldf(e2_ccc_devs).round(3).to_frame())\n",
758+
"nb_display(combine_ldf(e2_ccc_devs).round(3).to_frame().rename_axis(\"\"))\n",
754759
"print('PART 4 - Selected Age-to-Age Factors')\n",
755760
"print('Selected')\n",
756761
"nb_display(e2_ccc_selected.ldf_)\n",
@@ -800,7 +805,7 @@
800805
"print('PART 2 - Age-to-Age Factors')\n",
801806
"nb_display(e2_tri['Reported Claim Counts'].age_to_age.round(3))\n",
802807
"print('PART 3 - Average Age-to-Age Factor')\n",
803-
"nb_display(combine_ldf(e2_rcc_devs).round(3).to_frame())\n",
808+
"nb_display(combine_ldf(e2_rcc_devs).round(3).to_frame().rename_axis(\"\"))\n",
804809
"print('PART 4 - Selected Age-to-Age Factors')\n",
805810
"print('Selected')\n",
806811
"nb_display(e2_rcc_selected.ldf_)\n",
@@ -952,7 +957,7 @@
952957
"print('PART 2 - Age-to-Age Factors')\n",
953958
"nb_display(e2_rsev.age_to_age.round(3))\n",
954959
"print('PART 3 - Average Age-to-Age Factors')\n",
955-
"nb_display(combine_ldf(e2_rsev_devs).round(3).to_frame())\n",
960+
"nb_display(combine_ldf(e2_rsev_devs).round(3).to_frame().rename_axis(\"\"))\n",
956961
"print('PART 4 - Selected Age-to-Age Factors')\n",
957962
"nb_display(e2_rsev_selected.ldf_)\n",
958963
"print('CDF to Ultimate')\n",
@@ -1237,7 +1242,7 @@
12371242
"print('PART 2 - Age-to-Age Factors')\n",
12381243
"nb_display(e3_tri['Closed Claim Counts'].age_to_age.round(3))\n",
12391244
"print('PART 3 - Average Age-to-Age Factor')\n",
1240-
"nb_display(combine_ldf(e3_ccc_devs).round(3).to_frame())\n",
1245+
"nb_display(combine_ldf(e3_ccc_devs).round(3).to_frame().rename_axis(\"\"))\n",
12411246
"print('PART 4 - Selected Age-to-Age Factors')\n",
12421247
"print('Selected')\n",
12431248
"nb_display(e3_ccc_selected.ldf_)\n",
@@ -1286,7 +1291,7 @@
12861291
"print('PART 2 - Age-to-Age Factors')\n",
12871292
"nb_display(e3_tri['Reported Claim Counts'].age_to_age.round(3))\n",
12881293
"print('PART 3 - Average Age-to-Age Factor')\n",
1289-
"nb_display(combine_ldf(e3_rcc_devs).round(3).to_frame())\n",
1294+
"nb_display(combine_ldf(e3_rcc_devs).round(3).to_frame().rename_axis(\"\"))\n",
12901295
"print('PART 4 - Selected Age-to-Age Factors')\n",
12911296
"nb_display(e3_rcc_selected.ldf_)\n",
12921297
"print('CDF to Ultimate')\n",
@@ -1499,7 +1504,7 @@
14991504
"print('PART 2 - Age-to-Age Factors')\n",
15001505
"nb_display(e3_psev.age_to_age.round(3))\n",
15011506
"print('PART 3 - Average Age-to-Age Factor')\n",
1502-
"nb_display(combine_ldf(e3_psev_devs).round(3).to_frame())\n",
1507+
"nb_display(combine_ldf(e3_psev_devs).round(3).to_frame().rename_axis(\"\"))\n",
15031508
"print('PART 4 - Selected Age-to-Age Factors')\n",
15041509
"print('Selected')\n",
15051510
"nb_display(e3_psev_selected.ldf_)\n",
@@ -1546,7 +1551,7 @@
15461551
"print('PART 2 - Age-to-Age Factors')\n",
15471552
"nb_display(e3_rsev.age_to_age.round(3))\n",
15481553
"print('PART 3 - Average Age-to-Age Factor')\n",
1549-
"nb_display(combine_ldf(e3_rsev_devs).round(3).to_frame())\n",
1554+
"nb_display(combine_ldf(e3_rsev_devs).round(3).to_frame().rename_axis(\"\"))\n",
15501555
"print('PART 4 - Selected Age-to-Age Factors')\n",
15511556
"print('Selected')\n",
15521557
"nb_display(e3_rsev_selected.ldf_)\n",
@@ -1600,10 +1605,20 @@
16001605
")\n",
16011606
"e3_s8[['Reported Sev','Reported CDF','Ult Reported Sev']] = e3_resv_df[['Latest','CDF','Ultimate']]\n",
16021607
"e3_s8[\"Selected Ult Sev\"] = e3_sev_ult.latest_diagonal.to_frame()\n",
1603-
"e3_s8[['Paid CDF','Reported CDF']] = e3_s8[['Paid CDF','Reported CDF']].round(3)\n",
1604-
"#using floating point offset to achieve standard rounding\n",
1605-
"e3_s8[['Paid Sev','Reported Sev','Ult Paid Sev','Ult Reported Sev','Selected Ult Sev']] = (e3_s8[['Paid Sev','Reported Sev','Ult Paid Sev','Ult Reported Sev','Selected Ult Sev']] + 1e-9).round(0)\n",
1606-
"e3_s8.iloc[:-2,:][['Age','Paid Sev','Reported Sev','Paid CDF','Reported CDF','Ult Paid Sev','Ult Reported Sev','Selected Ult Sev']]"
1608+
"format_exh(\n",
1609+
" e3_s8.iloc[:-2,:],\n",
1610+
" [\n",
1611+
" 'Paid Sev',\n",
1612+
" 'Reported Sev',\n",
1613+
" 'Ult Paid Sev',\n",
1614+
" 'Ult Reported Sev',\n",
1615+
" 'Selected Ult Sev',\n",
1616+
" ],\n",
1617+
" [\n",
1618+
" 'Paid CDF',\n",
1619+
" 'Reported CDF',\n",
1620+
" ],\n",
1621+
")"
16071622
]
16081623
},
16091624
{
@@ -1646,12 +1661,21 @@
16461661
"e3_s9[['Sev Trend']] = e3_s9[['Sev Trend']].round(3)\n",
16471662
"#using floating point offset to achieve standard rounding\n",
16481663
"e3_s9[['Trended Ult Sev']] = (e3_s9[['Trended Ult Sev']] + 1e-9).round(0)\n",
1649-
"nb_display(e3_s9.iloc[:-2,:])\n",
1664+
"nb_display(format_exh(\n",
1665+
" e3_s9.iloc[:-2,:],\n",
1666+
" [\n",
1667+
" 'Selected Ult Sev',\n",
1668+
" 'Trended Ult Sev',\n",
1669+
" ],\n",
1670+
" [\n",
1671+
" 'Sev Trend',\n",
1672+
" ],\n",
1673+
"))\n",
16501674
"print('Average Trended Severity at 2008 Cost Level')\n",
16511675
"for k,v in e3_sevs.items():\n",
1652-
" print(f\"\\t{k:<20} \\t{v.round(0)}\")\n",
1653-
"print(f\"Selected 2008 Severity \\t\\t{e3_sev_2008:.0f}\")\n",
1654-
"print(f\"Estimated 2007 Severity \\t{e3_sev_2007:.0f}\")"
1676+
" print(f\"\\t{k:<20} \\t{v:,.0f}\")\n",
1677+
"print(f\"Selected 2008 Severity \\t\\t{e3_sev_2008:,.0f}\")\n",
1678+
"print(f\"Estimated 2007 Severity \\t{e3_sev_2007:,.0f}\")"
16551679
]
16561680
},
16571681
{
@@ -1698,7 +1722,22 @@
16981722
"e3_s10['Case Outstanding'] = e3_s10['Reported Claims'] - e3_s10['Paid Claims']\n",
16991723
"e3_s10['IBNR'] = e3_s10['Ult Claims'] - e3_s10['Reported Claims']\n",
17001724
"e3_s10['Unpaid'] = e3_s10['IBNR'] + e3_s10['Case Outstanding']\n",
1701-
"e3_s10.T"
1725+
"format_exh(\n",
1726+
" e3_s10,\n",
1727+
" [\n",
1728+
" 'Payroll',\n",
1729+
" 'Ult CC',\n",
1730+
" 'Selected Severity',\n",
1731+
" 'Ult Claims',\n",
1732+
" 'Reported Claims',\n",
1733+
" 'Paid Claims',\n",
1734+
" 'Case Outstanding',\n",
1735+
" 'IBNR',\n",
1736+
" 'Unpaid'\n",
1737+
" ],\n",
1738+
" [],\n",
1739+
" {'Selected Frequency':'{:.2%}'}\n",
1740+
")"
17021741
]
17031742
},
17041743
{
@@ -2186,7 +2225,7 @@
21862225
"print('PART 2 - Age-to-Age Factors')\n",
21872226
"nb_display(e5_tri['Closed Claim Counts'].age_to_age.round(3))\n",
21882227
"print('PART 3 - Average Age-to-Age Factor')\n",
2189-
"nb_display(combine_ldf(e5_ccc_devs).round(3).to_frame())\n",
2228+
"nb_display(combine_ldf(e5_ccc_devs).round(3).to_frame().rename_axis(\"\"))\n",
21902229
"print('PART 4 - Selected Age-to-Age Factors')\n",
21912230
"print('Selected')\n",
21922231
"nb_display(e5_ccc_selected.ldf_)\n",
@@ -2235,7 +2274,7 @@
22352274
"print('PART 2 - Age-to-Age Factors')\n",
22362275
"nb_display(e5_tri['Reported Claim Counts'].age_to_age.round(3))\n",
22372276
"print('PART 3 - Average Age-to-Age Factor')\n",
2238-
"nb_display(combine_ldf(e5_rcc_devs).round(3).to_frame())\n",
2277+
"nb_display(combine_ldf(e5_rcc_devs).round(3).to_frame().rename_axis(\"\"))\n",
22392278
"print('PART 4 - Selected Age-to-Age Factors')\n",
22402279
"nb_display(e5_rcc_selected.ldf_)\n",
22412280
"print('CDF to Ultimate')\n",

0 commit comments

Comments
 (0)