Replies: 1 comment
-
|
being able to easy set the display to be in thousands or millions would be great. I rely on displaying triangles in notebooks quite a bit. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While working on #856, I came across numeric formatting options that we currently don't offer in
cl.Options. These would be things like display precision and thousands separators. I also noticed the potential for adding formatting options when reviewing @henrydingliu's work on the Friedland reconciliation and summary exhibits.There is some amount of custom formatting done internally, such as adding a thousands separator and changing the precision based on the magnitude of the triangle's values when displaying in a Jupyter Notebook:
chainladder-python/chainladder/core/display.py
Lines 99 to 117 in 449b5c1
This can be seen on the onboarding tutorials in the differences between the display of a Pandas DataFrame and Chainladder Triangle:
I think for printing to console, chainladder defaults to whatever the pandas settings are:
raa = cl.load_sample('raa') raa Out[4]: 12 24 36 48 60 72 84 96 108 120 1981 5012.0 8269.0 10907.0 11805.0 13539.0 16181.0 18009.0 18608.0 18662.0 18834.0 1982 106.0 4285.0 5396.0 10666.0 13782.0 15599.0 15496.0 16169.0 16704.0 NaN 1983 3410.0 8992.0 13873.0 16141.0 18735.0 22214.0 22863.0 23466.0 NaN NaN 1984 5655.0 11555.0 15766.0 21266.0 23425.0 26083.0 27067.0 NaN NaN NaN 1985 1092.0 9565.0 15836.0 22169.0 25955.0 26180.0 NaN NaN NaN NaN 1986 1513.0 6445.0 11702.0 12935.0 15852.0 NaN NaN NaN NaN NaN 1987 557.0 4020.0 10946.0 12314.0 NaN NaN NaN NaN NaN NaN 1988 1351.0 6947.0 13112.0 NaN NaN NaN NaN NaN NaN NaN 1989 3133.0 5395.0 NaN NaN NaN NaN NaN NaN NaN NaN 1990 2063.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN raa.link_ratio Out[5]: 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120 1981 1.649840 1.319023 1.082332 1.146887 1.195140 1.112972 1.033261 1.002902 1.009217 1982 40.424528 1.259277 1.976649 1.292143 1.131839 0.993397 1.043431 1.033088 NaN 1983 2.636950 1.542816 1.163483 1.160709 1.185695 1.029216 1.026374 NaN NaN 1984 2.043324 1.364431 1.348852 1.101524 1.113469 1.037726 NaN NaN NaN 1985 8.759158 1.655619 1.399912 1.170779 1.008669 NaN NaN NaN NaN 1986 4.259749 1.815671 1.105367 1.225512 NaN NaN NaN NaN NaN 1987 7.217235 2.722886 1.124977 NaN NaN NaN NaN NaN NaN 1988 5.142117 1.887433 NaN NaN NaN NaN NaN NaN NaN 1989 1.721992 NaN NaN NaN NaN NaN NaN NaN NaNUnless there's another way, I think when printing to console, you'd need to adjust the Pandas settings. You'd need to do this for individual triangles, as changing session-wide settings makes no distinction between loss and link ratio values:
import pandas as pd pd.options.display.float_format = "{:,.0f}".format raa Out[10]: 12 24 36 48 60 72 84 96 108 120 1981 5,012 8,269 10,907 11,805 13,539 16,181 18,009 18,608 18,662 18,834 1982 106 4,285 5,396 10,666 13,782 15,599 15,496 16,169 16,704 NaN 1983 3,410 8,992 13,873 16,141 18,735 22,214 22,863 23,466 NaN NaN 1984 5,655 11,555 15,766 21,266 23,425 26,083 27,067 NaN NaN NaN 1985 1,092 9,565 15,836 22,169 25,955 26,180 NaN NaN NaN NaN 1986 1,513 6,445 11,702 12,935 15,852 NaN NaN NaN NaN NaN 1987 557 4,020 10,946 12,314 NaN NaN NaN NaN NaN NaN 1988 1,351 6,947 13,112 NaN NaN NaN NaN NaN NaN NaN 1989 3,133 5,395 NaN NaN NaN NaN NaN NaN NaN NaN 1990 2,063 NaN NaN NaN NaN NaN NaN NaN NaN NaN raa.link_ratio Out[11]: 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120 1981 2 1 1 1 1 1 1 1 1 1982 40 1 2 1 1 1 1 1 NaN 1983 3 2 1 1 1 1 1 NaN NaN 1984 2 1 1 1 1 1 NaN NaN NaN 1985 9 2 1 1 1 NaN NaN NaN NaN 1986 4 2 1 1 NaN NaN NaN NaN NaN 1987 7 3 1 NaN NaN NaN NaN NaN NaN 1988 5 2 NaN NaN NaN NaN NaN NaN NaN 1989 2 NaN NaN NaN NaN NaN NaN NaN NaNI'm mostly jotting down these thoughts so I don't forget, and I currently don't have a request specific enough to turn into an issue. I also wanted to start a discussion gauge how useful having chainladder-level options to control the formatting would be. I think at a minimum though, we should move any default formatting to a central location in the library, such as
__init__.pywhere all the current options are, which we could expand to its own module if it gets big enough.Beta Was this translation helpful? Give feedback.
All reactions