Having issue converting to traingle from long format (first time user of package) #452
-
Hello guys, I am trying to build a model but keep running into the same issue- I convert my existing triangle into long and then input it into the triangle function but I get the weirdest triangle as an output. I have attached the code and the result, please help me out!! Get the file pathfile_path = os.path.join('C:\Users\akhan\Desktop', 'Data.xlsx') Import the Excel filedf = pd.read_excel(file_path, sheet_name='Gross Paid') Convert to Long Formdf = pd.melt(df, id_vars='Loss Origin', value_vars=list(range(1, df.shape[1])),var_name='Period', value_name='Amount') Remove NA Valuesdf = df.dropna().reset_index() Drop Index column if needed + Rename the columnsdf = df.drop('index', axis=1) Change format of Origin + Create valuation columndf['origin'] = pd.to_datetime(df['origin'], format='%Y%m') tri = cl.Triangle( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @AmaanAliK, can you share your dataset? Or even just a sample of it? |
Beta Was this translation helpful? Give feedback.
-
DataScaled.xlsx |
Beta Was this translation helpful? Give feedback.
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
andpandas
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:Be sure that you are on version
0.8.17
!