-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Description
Chainladder supports the renaming of columns, but in order to do so for multiple-column triangles, you'd have to pass a list of new column names of the same length as the list of old column names, and in the same order.
For triangles with lots of columns (let's say 10+), this becomes error prone and verbose, especially if you only want to rename one or two columns. The rest of the columns have to be in the same order, and of the same spelling.
pandas can rename DataFrame columns via a mapping dictionary, where you only need to specify the columns you want to rename:
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
df.rename(columns={"A": "a", "B": "c"})
a c
0 1 4
1 2 5
2 3 6Is your feature request aligned with the scope of the package?
- Yes, absolutely!
- No, but it's still worth discussing.
- N/A (this request is not a codebase enhancement).
Describe the solution you'd like, or your current workaround.
Consider a triangle with columns ['Paid Loss', 'Incurred Loss', 'Subrogation']. If we wanted to rename 'Incurred Loss' to 'Reported Loss', we should be able to do:
triangle.rename(columns={'Incurred Loss': 'Reported Loss'})The current way to do this is more verbose, requiring the inclusion of 'Paid Loss' and 'Subrogation', even when they aren't being renamed. Mistyping or reordering these names will create semantic errors which will not be raised to the user:
triangle.rename(axis='columns', value=['Paid Loss', 'Reported Loss', 'Subrogation'])Do you have any additional supporting notes?
No response