From 9ab8269ea335d0e4efc244699a88377c6b1be393 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Mon, 25 Sep 2023 07:15:59 +0200 Subject: [PATCH] Removed some pandas warnings --- openquake/risklib/reinsurance.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openquake/risklib/reinsurance.py b/openquake/risklib/reinsurance.py index 0b93d70ac43e..21b1a07f9ed6 100644 --- a/openquake/risklib/reinsurance.py +++ b/openquake/risklib/reinsurance.py @@ -56,12 +56,12 @@ def check_fields(fields, dframe, policyidx, fname, policyfname, treaties, :param treaty_types: treaty types """ key = fields[0] - [indices] = np.where(dframe.deductible.to_numpy() == '') + [indices] = np.where(np.isnan(dframe.deductible.to_numpy())) if len(indices) > 0: raise InvalidFile( '%s (rows %s): empty deductible values were found' % ( policyfname, [idx + 2 for idx in indices])) - [indices] = np.where(dframe.liability.to_numpy() == '') + [indices] = np.where(np.isnan(dframe.liability.to_numpy())) if len(indices) > 0: raise InvalidFile( '%s (rows %s): empty liability values were found' % ( @@ -234,8 +234,7 @@ def parse(fname, policy_idx): treaty['limit'].append(limit) treaty_linenos.append(node.lineno) policyfname = os.path.join(os.path.dirname(fname), ~rmodel.policies) - df = pd.read_csv(policyfname, keep_default_na=False).rename( - columns=fieldmap) + df = pd.read_csv(policyfname).rename(columns=fieldmap) df.columns = df.columns.str.strip() all_policies = df.policy.to_numpy() # ex ['A', 'B'] exp_policies = np.array(list(policy_idx)) # ex ['?', 'B', 'A']