Skip to content

Commit 7b6ea51

Browse files
committed
silence deprecation notice
1 parent 89ec3f5 commit 7b6ea51

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

chainladder/core/pandas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ def to_frame(self, origin_as_datetime=None, keepdims=False,
144144

145145
def plot(self, *args, **kwargs):
146146
""" Passthrough of pandas functionality """
147-
return self.to_frame().plot(*args, **kwargs)
147+
return self.to_frame(origin_as_datetime=False).plot(*args, **kwargs)
148148

149149
def hvplot(self, *args, **kwargs):
150150
""" Passthrough of pandas functionality """
151-
df = self.to_frame()
151+
df = self.to_frame(origin_as_datetime=True)
152152
if type(df.index) == pd.PeriodIndex and len(df.columns) > 1:
153153
df.index = df.index.to_timestamp(how="s")
154154
return df.hvplot(*args, **kwargs)
@@ -238,7 +238,7 @@ def drop(self, labels=None, axis=1):
238238

239239
@property
240240
def T(self):
241-
return self.to_frame().T
241+
return self.to_frame(origin_as_datetime=False).T
242242

243243
def groupby(self, by, axis=0, *args, **kwargs):
244244
""" Group Triangle by index values. If the triangle is convertable to a

chainladder/core/tests/test_triangle.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
def test_repr(raa):
1414
np.testing.assert_array_equal(
1515
pd.read_html(raa._repr_html_())[0].set_index("Unnamed: 0").values,
16-
raa.to_frame().values,
16+
raa.to_frame(origin_as_datetime=False).values,
1717
)
1818

1919

2020
def test_to_frame_unusual(clrd):
21-
a = clrd.groupby(["LOB"]).sum().latest_diagonal["CumPaidLoss"].to_frame()
22-
b = clrd.latest_diagonal["CumPaidLoss"].groupby(["LOB"]).sum().to_frame()
21+
a = clrd.groupby(["LOB"]).sum().latest_diagonal["CumPaidLoss"].to_frame(origin_as_datetime=False)
22+
b = clrd.latest_diagonal["CumPaidLoss"].groupby(["LOB"]).sum().to_frame(origin_as_datetime=False)
2323
assert (a == b).all().all()
2424

2525

@@ -112,7 +112,7 @@ def test_quantile_vs_median(clrd):
112112

113113

114114
def test_base_minimum_exposure_triangle(raa):
115-
d = (raa.latest_diagonal * 0 + 50000).to_frame().reset_index()
115+
d = (raa.latest_diagonal * 0 + 50000).to_frame(origin_as_datetime=False).reset_index()
116116
d["index"] = d["index"].astype(str)
117117
cl.Triangle(d, origin="index", columns=d.columns[-1])
118118

@@ -190,7 +190,7 @@ def test_dropna(clrd):
190190
def test_exposure_tri():
191191
x = cl.load_sample("auto")
192192
x = x[x.development == 12]
193-
x = x["paid"].to_frame().T.unstack().reset_index()
193+
x = x["paid"].to_frame(origin_as_datetime=False).T.unstack().reset_index()
194194
x.columns = ["LOB", "origin", "paid"]
195195
x.origin = x.origin.astype(str)
196196
y = cl.Triangle(x, origin="origin", index="LOB", columns="paid")
@@ -215,13 +215,13 @@ def test_jagged_2_add(raa):
215215

216216
def test_df_period_input(raa):
217217
d = raa.latest_diagonal
218-
df = d.to_frame().reset_index()
218+
df = d.to_frame(origin_as_datetime=False).reset_index()
219219
assert cl.Triangle(df, origin="index", columns=df.columns[-1]) == d
220220

221221

222222
def test_trend_on_vector(raa):
223223
d = raa.latest_diagonal
224-
assert d.trend(0.05, axis=2).to_frame().astype(int).iloc[0, 0] == 29217
224+
assert d.trend(0.05, axis=2).to_frame(origin_as_datetime=False).astype(int).iloc[0, 0] == 29217
225225

226226

227227
def test_latest_diagonal_val_to_dev(raa):
@@ -248,11 +248,12 @@ def test_groupby_axis1(clrd, prism):
248248
clrd = clrd.sum("origin").sum("development")
249249
groups = [i.find("Loss") >= 0 for i in clrd.columns]
250250
assert np.all(
251-
clrd.to_frame().groupby(groups, axis=1).sum()
252-
== clrd.groupby(groups, axis=1).sum().to_frame()
251+
clrd.to_frame(origin_as_datetime=False).groupby(groups, axis=1).sum()
252+
== clrd.groupby(groups, axis=1).sum().to_frame(origin_as_datetime=False)
253253
)
254254
assert np.all(
255-
clrd.to_frame().groupby("LOB").sum() == clrd.groupby("LOB").sum().to_frame()
255+
clrd.to_frame(origin_as_datetime=False).groupby("LOB").sum() ==
256+
clrd.groupby("LOB").sum().to_frame(origin_as_datetime=False)
256257
)
257258
prism.sum().grain("OYDY")
258259

@@ -262,7 +263,7 @@ def test_partial_year(prism):
262263
before=before[before.valuation<='2017-08'].latest_diagonal
263264

264265
after = cl.Triangle(
265-
before.to_frame(keepdims=True).reset_index(),
266+
before.to_frame(keepdims=True, origin_as_datetime=True).reset_index(),
266267
origin='origin', development='valuation', columns='Paid', index=before.key_labels)
267268

268269
assert after.valuation_date == before.valuation_date
@@ -294,7 +295,7 @@ def test_shift(raa):
294295
assert (
295296
raa.iloc[..., 1:-1, 1:-1] -
296297
raa.shift(-1, axis=2).shift(-1, axis=3).shift(2, axis=2).shift(2, axis=3).dropna().values
297-
).to_frame().fillna(0).sum().sum() == 0
298+
).to_frame(origin_as_datetime=False).fillna(0).sum().sum() == 0
298299

299300

300301
def test_array_protocol2(raa):
@@ -305,7 +306,7 @@ def test_array_protocol2(raa):
305306
def test_create_full_triangle(raa):
306307
a = cl.Chainladder().fit(raa).full_triangle_
307308
b = cl.Triangle(
308-
a.to_frame(keepdims=True, implicit_axis=True),
309+
a.to_frame(keepdims=True, implicit_axis=True, origin_as_datetime=True),
309310
origin='origin', development='valuation', columns='values')
310311
assert a == b
311312

@@ -322,7 +323,7 @@ def test_virtual_column(prism):
322323

323324
def test_correct_valutaion(raa):
324325
new = cl.Triangle(
325-
raa.iloc[..., :-3, :].latest_diagonal.to_frame(keepdims=True, implicit_axis=True),
326+
raa.iloc[..., :-3, :].latest_diagonal.to_frame(keepdims=True, implicit_axis=True, origin_as_datetime=True),
326327
origin='origin', development='valuation', columns='values')
327328
assert new.valuation_date == raa.valuation_date
328329

@@ -391,7 +392,7 @@ def test_trailing_origin():
391392
assert tri.origin_close == 'JUN'
392393

393394
def test_trailing_valuation():
394-
data = cl.load_sample('raa').dev_to_val().to_frame(keepdims=True)
395+
data = cl.load_sample('raa').dev_to_val().to_frame(keepdims=True, origin_as_datetime=True)
395396
data.valuation = (data.valuation.dt.year+1)*100+3
396397
tri = cl.Triangle(data, origin='origin', development='valuation', columns='values')
397398
assert tri.development.to_list() == [3, 15, 27, 39, 51, 63, 75, 87, 99, 111, 123]
@@ -409,7 +410,7 @@ def test_edgecase_236():
409410

410411

411412
def test_to_frame_on_zero(clrd):
412-
assert len((clrd*0).latest_diagonal.to_frame()) == 0
413+
assert len((clrd*0).latest_diagonal.to_frame(origin_as_datetime=False)) == 0
413414

414415
def test_valuation_vector():
415416
df = pd.DataFrame(

chainladder/development/munich.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def lambda_(self):
369369
obj.odims = obj.odims[0:1]
370370
obj.ddims = obj.ddims[0:1]
371371
obj.values = self._reshape("lambda_coef_")
372-
return obj.to_frame()
372+
return obj.to_frame(origin_as_datetime=False)
373373

374374
@property
375375
def basic_cdf_(self):

chainladder/methods/tests/test_capecod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_groupby(clrd):
1717
clrd = clrd[clrd['LOB']=='comauto']
1818
# But only the top 10 get their own CapeCod aprioris. Smaller companies get grouped together
1919
top_10 = clrd['EarnedPremDIR'].groupby('GRNAME').sum().latest_diagonal
20-
top_10 = top_10.loc[..., '1997', :].to_frame().nlargest(10)
20+
top_10 = top_10.loc[..., '1997', :].to_frame(origin_as_datetime=True).nlargest(10)
2121
cc_groupby = clrd.index['GRNAME'].map(lambda x: x if x in top_10.index else 'Remainder')
2222
idx = clrd.index
2323
idx['Top 10'] = cc_groupby

chainladder/methods/tests/test_mack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_mack_asymmetric():
148148
tri = cl.load_sample("quarterly")["paid"]
149149
xp = tri.get_array_module()
150150
assert round(float(xp.array(out.rx("Mack.S.E")[0])[-1, -1]), 2) == round(
151-
float(cl.MackChainladder().fit(tri).summary_.to_frame().iloc[-1, -1]), 2
151+
float(cl.MackChainladder().fit(tri).summary_.to_frame(origin_as_datetime=False).iloc[-1, -1]), 2
152152
)
153153

154154
def test_mack_malformed():

0 commit comments

Comments
 (0)