Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address some pandas FuturesWarnings #653

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/environments/local/local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def run(self) -> Tuple[Status, Optional[Dict[str, TunableValue]]]:
_LOG.info("Local results have (metric,value) header and %d rows: assume long format", len(data))
data = pandas.DataFrame([data.value.to_list()], columns=data.metric.to_list())
# Try to convert string metrics to numbers.
data = data.apply(pandas.to_numeric, errors="ignore") # type: ignore[assignment] # (false positive)
data = data.apply(pandas.to_numeric, errors='coerce').fillna(data) # type: ignore[assignment] # (false positive)
elif len(data) == 1:
_LOG.info("Local results have 1 row: assume wide format")
else:
Expand Down
6 changes: 4 additions & 2 deletions mlos_bench/mlos_bench/storage/sql/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def get_results_df(
columns=['trial_id', 'tunable_config_id', 'param', 'value']
).pivot(
index=["trial_id", "tunable_config_id"], columns="param", values="value",
).apply(pandas.to_numeric, errors='ignore')
)
configs_df = configs_df.apply(pandas.to_numeric, errors='coerce').fillna(configs_df) # type: ignore[assignment] # (fp)

# Get each trial's results in wide format.
results_stmt = schema.trial_result.select().with_only_columns(
Expand All @@ -164,7 +165,8 @@ def get_results_df(
columns=['trial_id', 'metric', 'value']
).pivot(
index="trial_id", columns="metric", values="value",
).apply(pandas.to_numeric, errors='ignore')
)
results_df = results_df.apply(pandas.to_numeric, errors='coerce').fillna(results_df) # type: ignore[assignment] # (fp)

# Concat the trials, configs, and results.
return trials_df.merge(configs_df, on=["trial_id", "tunable_config_id"], how="left") \
Expand Down
Loading