Store origin label as an attribute
Related to #416. I propose we keep the origin label metadata, this way the user can distinguish between different origin bases, such as accident year vs policy year, etc.
cl.load_sample('xyz')
Triangle Summary
Valuation: 2008-12
Grain: OYDY
Shape: (1, 5, 11, 11)
Index: [Total]
Origin: [AccidentYear]
Columns: [Incurred, Paid, Reported, Closed, Premium]
I think some unit tests are failing likely because the olab field isn't being passed through in all the transform methods. Without investiagting, it may need to also be added to some of the serializing/deserializing functions like to_json and read_json. I'm not sure, but the unit test failures should implicate gaps.
@genedan do you still need the origin label in the metadata? I can help take a look at this.
Yeah that would be good. I'm a little bogged down at the moment so I would appreciate it.
Just so I understand this request, you basically want to know what built the Triangle object, and be able to get the strings back from the DataFrame right? For example:
import chainladder as cl
import pandas as pd
xyz = cl.load_sample("xyz")
Yields:
cl.load_sample('xyz')
Triangle Summary
Valuation: 2008-12
Grain: OYDY
Shape: (1, 5, 11, 11)
Index: [Total]
Origin: [AccidentYear]
Columns: [Incurred, Paid, Reported, Closed, Premium]
And you need something that'll do this?
print("columns_label:", xyz.columns_label)
print("index_label:", xyz.index_label)
print("origin_label:", xyz.origin_label)
Returns:
columns_label: ['Incurred', 'Paid', 'Reported', 'Closed', 'Premium']
index_label: ['Total']
origin_label: ['AccidentYear']
You should now be able to do all of the following:
import chainladder as cl
xyz = cl.load_sample("xyz")
print("valuation_date:", xyz.valuation_date)
print("origin_grain:", xyz.origin_grain)
print("development_grain:", xyz.development_grain)
print("xyz.shape:", xyz.shape)
print("index_label:", xyz.index_label)
print("columns_label:", xyz.columns_label)
print("origin_label:", xyz.origin_label)
Everything in the Triangle summary is now visiable as attributes.