From f06536d4ac1ea0ddf00c1255fc37316ded089caf Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Thu, 4 Jun 2026 15:59:40 -0700 Subject: [PATCH 1/2] Added development_format --- chainladder/utils/data/_manifest.py | 4 ++++ chainladder/utils/utility_functions.py | 17 +++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/chainladder/utils/data/_manifest.py b/chainladder/utils/data/_manifest.py index bf21d808..75702d6a 100644 --- a/chainladder/utils/data/_manifest.py +++ b/chainladder/utils/data/_manifest.py @@ -27,6 +27,8 @@ Measure column name(s) loaded into the Triangle. ``cumulative`` ``True`` if the measures are cumulative, ``False`` if incremental. +``development_format`` + Optional. Passed to ``Triangle`` by :func:`chainladder.load_sample`. """ SAMPLES: dict = { @@ -157,6 +159,7 @@ "Paid Claims", ], "cumulative": True, + "development_format": "%Y-12-31", }, "friedland_med_mal": { "origin": "Accident Year", @@ -169,6 +172,7 @@ "Open Claim Counts", ], "cumulative": True, + "development_format": "%Y", }, "friedland_qs": { "origin": "Accident Year", diff --git a/chainladder/utils/utility_functions.py b/chainladder/utils/utility_functions.py index 7e8ac606..11335cb8 100644 --- a/chainladder/utils/utility_functions.py +++ b/chainladder/utils/utility_functions.py @@ -10,10 +10,7 @@ import numpy as np import pandas as pd -from chainladder import ( - __dt64_unit__, - __dt64_dtype__ -) +from chainladder import __dt64_unit__, __dt64_dtype__ from chainladder.utils.sparse import sp from chainladder.utils.data._manifest import SAMPLES from io import StringIO @@ -117,6 +114,8 @@ def load_sample(key: str, *args, **kwargs) -> Triangle: columns = config["columns"] cumulative = config["cumulative"] + development_format = config.get("development_format", None) + df = pd.read_csv(filepath_or_buffer=dataset_path) return Triangle( @@ -126,6 +125,7 @@ def load_sample(key: str, *args, **kwargs) -> Triangle: index=index, columns=columns, cumulative=cumulative, + development_format=development_format, *args, **kwargs, ) @@ -818,6 +818,7 @@ def PTF_formula( return "+".join(formula_parts) return "" + def date_delta_adjustment(date: str) -> str: """ Subtracts the default pandas datetime delta from a date in "YYYY-MM-DD" string format. @@ -855,10 +856,6 @@ def date_delta_adjustment(date: str) -> str: '2025-10-31 23:59:59.999999' """ + res: str = str(pd.Timestamp(date) - pd.Timedelta(1, unit=__dt64_unit__)) - res: str = str( - pd.Timestamp(date) - \ - pd.Timedelta(1, unit=__dt64_unit__) - ) - - return res \ No newline at end of file + return res From 3993b4a8f3459780d2986b51281d953329b87ab0 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Thu, 4 Jun 2026 16:04:00 -0700 Subject: [PATCH 2/2] removed the development_format from friedland_med_mal --- chainladder/utils/data/_manifest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/chainladder/utils/data/_manifest.py b/chainladder/utils/data/_manifest.py index 75702d6a..21589a8e 100644 --- a/chainladder/utils/data/_manifest.py +++ b/chainladder/utils/data/_manifest.py @@ -172,7 +172,6 @@ "Open Claim Counts", ], "cumulative": True, - "development_format": "%Y", }, "friedland_qs": { "origin": "Accident Year",