chainladder.concat#
- chainladder.concat(objs: list | tuple, axis: int | str, ignore_index: bool = False, sort: bool = False)[source]#
Concatenate Triangle objects along a particular axis.
- Parameters:
- objs: list or tuple
A list or tuple of Triangle objects to concat. All non-concat axes must be identical and all elements of the concat axes must be unique.
- axis: string or int
The axis to concatenate along.
- ignore_index: bool, default False
If True, do not use the index values along the concatenation axis. The resulting axis will be labeled 0, …, n - 1. This is useful if you are concatenating objects where the concatenation axis does not have meaningful indexing information. Note the index values on the other axes are still respected in the join.
- sort: bool
If True, sort the result along the desired axis.
- Returns:
- Updated triangle
Examples
When paid and incurred triangles are constructed separately,
concatalongaxis=1combines them into one multi-column triangle, giving downstream methods access to both columns at once.clrd = cl.load_sample("clrd").groupby("LOB").sum() wkcomp = clrd.iloc[5:6] paid = wkcomp["CumPaidLoss"] incurred = wkcomp["IncurLoss"] combined = cl.concat([paid, incurred], axis=1) print(list(combined.columns))
['CumPaidLoss', 'IncurLoss']
When two triangles possess a column that the other does not have, their concatenation will fill in the missing values of each sub-triangle with xp.nan.
clrd = cl.load_sample('clrd') clrd = clrd.groupby("LOB").sum() t1 = clrd.loc["wkcomp"][["IncurLoss"]].rename("columns", ["A"]) t2 = clrd.loc["comauto"][["CumPaidLoss"]].rename("columns", ["B"]) result = cl.concat([t1, t2], axis=0) print(result.loc["wkcomp"]["B"])
12 24 36 48 60 72 84 96 108 120 1988 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1989 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1990 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1991 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1992 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1993 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1994 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1995 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1996 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1997 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN