diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/quote_parsing/parse_emails.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/python/quote_parsing/parse_emails.py b/python/quote_parsing/parse_emails.py index d8d81003..ae3d525d 100644 --- a/python/quote_parsing/parse_emails.py +++ b/python/quote_parsing/parse_emails.py @@ -53,9 +53,20 @@ def makedf(r, indextype, quote_source): try: df[col] = df[col].str.rstrip("%").astype("float") / 100 except ValueError: # typo in one email - df[col] = ( - pd.to_numeric(df[col].str.replace("n", "").str.rstrip("%")) / 100 - ) + try: + df[col] = ( + pd.to_numeric(df[col].str.replace("n", "").str.rstrip("%")) + / 100 + ) + except ValueError: + df[col] = ( + pd.to_numeric( + df[col].str.replace("n", "").str.rstrip("%"), + errors="coerce", + ) + / 100 + ) + if quote_source == "GS": for col in ["pay_bid", "pay_offer", "rec_bid", "rec_offer"]: df[col] = df[col].str.strip("-") @@ -587,7 +598,7 @@ def get_current_version(index, series, d, conn): "WHERE index=%s and series=%s and %s <= lastdate", (index.upper(), series, d), ) - version, = c.fetchone() + (version,) = c.fetchone() return version @@ -667,7 +678,7 @@ def write_todb(swaption_stack, index_data, conn): for t in index_data.itertuples(index=False): c.execute(sql_str, t) try: - ref_id, = next(c) + (ref_id,) = next(c) except StopIteration: continue else: |
