Skip to content

Commit

Permalink
Suppressing warning manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomerritt committed Mar 26, 2024
1 parent e356aee commit bf84d19
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/adler/dataclasses/dataclass_utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pandas as pd
import sqlite3
import warnings


def get_data_table(sql_query, service=None, sql_filename=None):
Expand Down Expand Up @@ -34,9 +35,12 @@ def get_data_table(sql_query, service=None, sql_filename=None):
data_table = pd.read_sql_query(
sql_query, cnx
) # would really like to move away from Pandas for this...
with pd.option_context(
"future.no_silent_downcasting", True
): # suppresses a useless FutureWarning: the below line accounts for the warned behaviour already

# Pandas is triggering a useless FutureWarning here which I am choosing to suppress.
# The code is already written to account for the FutureWarning, but it triggers anyway. Thanks, Pandas.
# Note that pd.option_context("future.no_silent_downcasting", True) would also work, but only for Pandas >2.0.3.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
data_table = data_table.fillna(value=np.nan).infer_objects(
copy=False
) # changes Nones to NaNs because None forces dtype=object: bad.
Expand Down

0 comments on commit bf84d19

Please sign in to comment.