Pandas now uses a default string type when it used to default to object type.
https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#dedicated-string-data-type-by-default
This will cause existing code that checks for type object to fail, such as line 424 in _drop_func:
|
def _drop_func(self, factor): |
|
# get the appropriate backend for nan_triangle and nan_to_num |
|
xp = factor.get_array_module() |
|
# turn single drop_valuation parameter to list if necessary |
|
drop_list = self.drop if isinstance(self.drop, list) else [self.drop] |
|
# get an starting array of weights |
|
arr = factor.nan_triangle.copy() |
|
# accommodate ldf triangle as factor, where the dimensions are '12-24' |
|
dev_list = ( |
|
factor.development.str.split("-", expand=True)[0] |
|
if factor.development.dtype == object |
|
else factor.development.astype("string") |
|
) |
|
# create ndarray of drop_list for further operation in numpy |
|
drop_np = np.asarray(drop_list) |
|
# find indices of drop_np |
|
origin_ind = np.where( |
|
np.array([factor.origin.astype("string")]) == drop_np[:, [0]] |
|
)[1] |
|
dev_ind = np.where(np.array([dev_list]) == drop_np[:, [1]])[1] |
|
# set weight of dropped factors to 0 |
|
arr[(origin_ind, dev_ind)] = 0 |
|
return xp.nan_to_num(arr)[None, None] |
As far as I can tell, this is the only place in the package where this happens and causes test failures.
Pandas now uses a default
stringtype when it used to default toobjecttype.https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#dedicated-string-data-type-by-default
This will cause existing code that checks for type
objectto fail, such as line 424 in _drop_func:chainladder-python/chainladder/development/base.py
Lines 414 to 436 in 6ea3577
As far as I can tell, this is the only place in the package where this happens and causes test failures.