Skip to content

Having issue converting to traingle from long format (first time user of package) #452

Answered by kennethshsu
AmaanAliK asked this question in Q&A
Discussion options

You must be logged in to vote

From looking at the data, I think we have a Quarter-by-Quarter triangle, is that right? The data, in its current form, is not clear for chainladder and pandas to understand. I try to keep your code as much as I can, but there are a few chagnes that are required. Take a look:

import chainladder as cl
import pandas as pd
import numpy as np

print(cl.__version__)

Be sure that you are on version 0.8.17!

df = pd.read_excel("/Users/kennethhsu/Downloads/DataScaled.xlsx")
df = pd.melt(
    df,
    id_vars="Loss Origin",
    value_vars=list(range(1, df.shape[1])),
    var_name="Period",
    value_name="Amount",
)
df = df.dropna().reset_index()
df = df.drop("index", axis=1)
df.columns = ["origin", "…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@kennethshsu
Comment options

Answer selected by AmaanAliK
@AmaanAliK
Comment options

@AmaanAliK
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants