Skip to content

Commit

Permalink
Removed some pandas warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Sep 25, 2023
1 parent b8bf1aa commit 9ab8269
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions openquake/risklib/reinsurance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' % (
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 9ab8269

Please sign in to comment.