Change the grain of my data #682
-
|
This is the first 15 rows of my data Origin | Month | Value | OriginDate | Develop I create the triangle and the grain is OYDY ConstTrian = cl.Triangle( I tried to change the grain back to OYDQ through ConstTrian.grain('OYDQ') The error is "ValueError: New grain not compatible with existing grain", which is strange since my data development was originally in quarter Any help on either loading the data or changing the grain is most welcome. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Your dates format are a bit unusual so I wonder if python is confused. I would recommend explicitly specifying the date format first. df = pd.read_csv("/Users/kennethhsu/Desktop/test.csv")
df["OriginDate"] = pd.to_datetime(df["OriginDate"], format="%d/%m/%y")
df["Develop"] = pd.to_datetime(df["Develop"], format="%d/%m/%y")Next, the valuation date should be the end of the month. So do this: df["Valuation"] = df["Develop"] - pd.Timedelta(days=1)
dfNow you are ready to go into triangle = cl.Triangle(
df,
origin="OriginDate",
development="Valuation",
columns="Value",
cumulative=True,
grain="OYDQ"
)
triangleCan you try the above and see if it works for you? |
Beta Was this translation helpful? Give feedback.
Your dates format are a bit unusual so I wonder if python is confused. I would recommend explicitly specifying the date format first.
Next, the valuation date should be the end of the month. So do this:
Now you are ready to go into
chainladder:Can you try the above and see if it works for you?