Skip to content

Commit

Permalink
pandas 2.0 timedetla patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogaardt committed Jun 17, 2023
1 parent 5510c94 commit 9b8b10c
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions chainladder/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,31 +254,10 @@ def _to_datetime(data, fields, period_end=False, format=None):

@staticmethod
def _development_lag(origin, valuation):
"""For tabular format, this will convert the origin/development
"""For tabular format, this will convert the origin/valuation
difference to a development lag"""
return ((valuation - origin) / (365/12)).round('1d').dt.days

temp = pd.DataFrame()
temp["valuation"] = (valuation + pd.DateOffset(1)).dt.strftime("%m/%d/%Y")
temp["origin"] = origin.dt.strftime("%m/%d/%Y")

temp["age_old"] = (
((valuation - origin) / np.timedelta64(1, "M")).round(0).astype(int)
)

temp["age_temp_div"] = (
(valuation.dt.year * 12 + valuation.dt.month)
- (origin.dt.year * 12 + origin.dt.month)
+ 1
)

# print(temp.tail(10))

# return ((valuation - origin) / np.timedelta64(1, "Y")).round(0).astype(int) * 12
return (
(valuation.dt.year * 12 + valuation.dt.month)
- (origin.dt.year * 12 + origin.dt.month)
+ 1
)

@staticmethod
def _get_grain(dates, trailing=False, kind="origin"):
Expand Down

0 comments on commit 9b8b10c

Please sign in to comment.