Skip to content

[ENH] Add example for creating a triangle with preexisting ultimates #523

Open
@genedan

Description

@genedan

There is some code that is executed early on in the Triangle constructor that handles the situation where the data contain ultimates:

@staticmethod
    def _split_ult(
            data: DataFrame,
            index: list,
            columns: list,
            origin: list,
            development: list
    ):
        """Deal with triangles with ultimate values"""
        ult = None
        if (
            development
            and len(development) == 1
            and data[development[0]].dtype == "<M8[ns]"
        ):
            u = data[data[development[0]] == options.ULT_VAL].copy()
            if len(u) > 0 and len(u) != len(data):
                ult = Triangle(
                    u,
                    origin=origin,
                    development=development,
                    columns=columns,
                    index=index,
                )
                ult.ddims = pd.DatetimeIndex([options.ULT_VAL])
                data = data[data[development[0]] != options.ULT_VAL]
        return data, ult

Is there a sample or anywhere in the documentation where we supply data with ultimates? From the code it's unclear to me how one would do explicitly, since the way ultimate values are detected depend on the the length of a list and the data type of the values, <M8[ns], which is obscure to me, rather than some explicit flag named "ultimate" or something resembling it.

It seems to me this was written to handle triangles that have already been developed via chainladder rather than as a way to allow the user a way to import ultimate data from the beginning. If it's the former case we can add enhance the docstring, but if the latter perhaps we could add an argument to the triangle constructor explicitly marking the existence of ultimate values.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions