Skip to content

Commit

Permalink
Merge pull request #643 from akrherz/240122
Browse files Browse the repository at this point in the history
mnt: address some pandas2.2 warnings
  • Loading branch information
akrherz authored Jan 22, 2024
2 parents 28b490c + 7f3791f commit d0eb346
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cgi-bin/request/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_data(network, sts, ets, stations, cols, na, fmt):
if fmt == "excel":
bio = BytesIO()
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "Data", index=False)
df.to_excel(writer, sheet_name="Data", index=False)
return bio.getvalue()

sio = StringIO()
Expand Down
4 changes: 2 additions & 2 deletions cgi-bin/request/feel.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def fmt(val):

bio = BytesIO()
with pd.ExcelWriter(bio, engine="openpyxl") as writer:
df.to_excel(writer, "Daily Data", index=False)
df2.to_excel(writer, "Hourly Data", index=False)
df.to_excel(writer, sheet_name="Daily Data", index=False)
df2.to_excel(writer, sheet_name="Hourly Data", index=False)

headers = [
("Content-type", EXL),
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/gis/lsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def do_excel_kml(fmt, sts, ets, wfolimiter, statelimiter):
bio = BytesIO()
# pylint: disable=abstract-class-instantiated
writer = pd.ExcelWriter(bio, engine="xlsxwriter")
df.to_excel(writer, "Local Storm Reports", index=False)
df.to_excel(writer, sheet_name="Local Storm Reports", index=False)
worksheet = writer.sheets["Local Storm Reports"]
worksheet.set_column("B:C", 36)
worksheet.set_column("D:E", 24)
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/gis/watchwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def do_excel(sql):
bio = BytesIO()
# pylint: disable=abstract-class-instantiated
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "VTEC WaWA", index=False)
df.to_excel(writer, sheet_name="VTEC WaWA", index=False)
return bio.getvalue()


Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/hads.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def application(environ, start_response):
if what == "excel":
bio = BytesIO()
with pd.ExcelWriter(bio, engine="openpyxl") as writer:
table.to_excel(writer, "Data", index=True)
table.to_excel(writer, sheet_name="Data", index=True)

headers = [
("Content-type", EXL),
Expand Down
4 changes: 3 additions & 1 deletion cgi-bin/request/isusm.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ def application(environ, start_response):
# pylint: disable=abstract-class-instantiated
if cols:
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "Data", columns=cols, index=False)
df.to_excel(
writer, sheet_name="Data", columns=cols, index=False
)
headers = [
("Content-type", EXL),
("Content-disposition", "attachment; Filename=isusm.xlsx"),
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/mos.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_data(sts, ets, station, model, fmt):
bio = BytesIO()
# pylint: disable=abstract-class-instantiated
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "Data", index=False)
df.to_excel(writer, sheet_name="Data", index=False)
return bio.getvalue()

sio = StringIO()
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/rwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_lon(station):
return [b"Dataset too large for excel format."]
bio = BytesIO()
with pd.ExcelWriter(bio) as writer:
df.to_excel(writer, "Data", index=False, columns=myvars)
df.to_excel(writer, sheet_name="Data", index=False, columns=myvars)

headers = [
("Content-type", EXL),
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/taf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run(start_response, ctx):
bio = BytesIO()
if ctx["fmt"] == "excel":
with pd.ExcelWriter(bio, engine="openpyxl") as writer:
df.to_excel(writer, "TAF Data", index=False)
df.to_excel(writer, sheet_name="TAF Data", index=False)
headers = [
("Content-type", EXL),
("Content-disposition", "attachment;Filename=taf.xlsx"),
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/talltowers.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def application(environ, start_response):
bio = BytesIO()
# pylint: disable=abstract-class-instantiated
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "Data", index=False)
df.to_excel(writer, sheet_name="Data", index=False)
headers = [
("Content-type", EXL),
("Content-disposition", "attachment; Filename=talltowers.xlsx"),
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/request/tempwind_aloft.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_data(station, sts, ets, tz, na, fmt):
if fmt == "excel":
bio = BytesIO()
with pd.ExcelWriter(bio, engine="xlsxwriter") as writer:
df.to_excel(writer, "Data", index=False)
df.to_excel(writer, sheet_name="Data", index=False)
return bio.getvalue()

sio = StringIO()
Expand Down
3 changes: 3 additions & 0 deletions deployment/mod_wsgi_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def warn_with_traceback(
)


# pandas 2.2 warning with fillna
pd.set_option("future.no_silent_downcasting", True)

warnings.showwarning = warn_with_traceback
# Stop pandas UserWarning for now in prod
if os.path.exists("/etc/IEMDEV"):
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies:
- odfpy
# excel output
- openpyxl
# yo
- pandas
# due to config settings
- pandas>=2.2
# mod-wsgi
- paste
# PIL
Expand Down

0 comments on commit d0eb346

Please sign in to comment.