From b1077496ce782cfa5ed5891543864daba177963d Mon Sep 17 00:00:00 2001 From: akrherz Date: Tue, 23 Jan 2024 10:50:21 -0600 Subject: [PATCH] mnt: roundup some pandas 2.2 fixes --- htdocs/plotting/auto/scripts200/p219.py | 8 +++++--- scripts/climodat/daily_estimator.py | 1 + scripts/climodat/hrrr_solarrad.py | 2 +- scripts/climodat/use_acis.py | 1 + scripts/isusm/agg_1minute.py | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/plotting/auto/scripts200/p219.py b/htdocs/plotting/auto/scripts200/p219.py index c897d54e4c..d7d4eea275 100644 --- a/htdocs/plotting/auto/scripts200/p219.py +++ b/htdocs/plotting/auto/scripts200/p219.py @@ -112,7 +112,6 @@ def plotter(fdict): """Go""" ctx = get_autoplot_context(fdict, get_description()) valid = ctx["valid"].replace(tzinfo=datetime.timezone.utc) - pgconn = get_dbconn("asos") def fetch(ts): """Getme data.""" @@ -129,11 +128,14 @@ def fetch(ts): df = fetch(valid) if df.empty: + pgconn = get_dbconn("asos") valid = taf_search(pgconn, ctx["station"], valid) + pgconn.close() if valid is None: raise NoDataFound("TAF data was not found!") df = fetch(valid) - df = df.fillna(np.nan) + # prevent all nan from becoming an object + df = df.fillna(np.nan).infer_objects() df["next_valid"] = ( df.reset_index().shift(-1)["valid"].values - df.index.values ) @@ -325,4 +327,4 @@ def fetch(ts): if __name__ == "__main__": - plotter({"station": "PGUM", "valid": "2023-09-28 0542"}) + plotter({}) diff --git a/scripts/climodat/daily_estimator.py b/scripts/climodat/daily_estimator.py index 8b70ec992e..44d29e1308 100644 --- a/scripts/climodat/daily_estimator.py +++ b/scripts/climodat/daily_estimator.py @@ -19,6 +19,7 @@ from pyiem.util import get_dbconn, get_sqlalchemy_conn, logger from sqlalchemy import text +pd.set_option("future.no_silent_downcasting", True) LOG = logger() NON_CONUS = ["AK", "HI", "PR", "VI", "GU", "AS"] diff --git a/scripts/climodat/hrrr_solarrad.py b/scripts/climodat/hrrr_solarrad.py index acdf98e933..462056acf5 100644 --- a/scripts/climodat/hrrr_solarrad.py +++ b/scripts/climodat/hrrr_solarrad.py @@ -97,7 +97,7 @@ def compute(df, sids, dt, do_regions=False): yaxis = None # date_range is inclusive for now in pd.date_range( - sts, sts + datetime.timedelta(hours=23), freq="1H" + sts, sts + datetime.timedelta(hours=23), freq="1h" ): # Try the newer f01 files, which have better data! fn = now.strftime( diff --git a/scripts/climodat/use_acis.py b/scripts/climodat/use_acis.py index 9e5a703ef7..ab602f5dc2 100644 --- a/scripts/climodat/use_acis.py +++ b/scripts/climodat/use_acis.py @@ -14,6 +14,7 @@ logger, ) +pd.set_option("future.no_silent_downcasting", True) LOG = logger() SERVICE = "http://data.rcc-acis.org/StnData" METASERVICE = "http://data.rcc-acis.org/StnMeta" diff --git a/scripts/isusm/agg_1minute.py b/scripts/isusm/agg_1minute.py index 5225bd3630..92ebfd4658 100644 --- a/scripts/isusm/agg_1minute.py +++ b/scripts/isusm/agg_1minute.py @@ -10,6 +10,7 @@ import pandas as pd from pyiem.util import get_dbconn, get_sqlalchemy_conn, logger, utc +pd.set_option("future.no_silent_downcasting", True) LOG = logger() TIME_FORMAT = "%Y-%m-%d %H:%M-06"