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

Multiple FutureWarning on Pandas 2.2.2 #38

Closed
tom91136 opened this issue Apr 18, 2024 · 1 comment · Fixed by #52
Closed

Multiple FutureWarning on Pandas 2.2.2 #38

tom91136 opened this issue Apr 18, 2024 · 1 comment · Fixed by #52
Labels
bug Something isn't working
Milestone

Comments

@tom91136
Copy link

Expected behavior

No warnings of any kind

Actual behavior

Multiple occurrences of the following:

/home/tom/p3-analysis-library/p3/metrics/_efficiency.py:58: FutureWarning: The provided callable <built-in function min> is currently using DataFrameGroupBy.min. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "min" instead.
  best = groups.agg(min) if foms == "lower" else groups.agg(max)
/home/tom/p3-analysis-library/p3/metrics/_efficiency.py:65: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
  best_fom = float(best.loc[(best[key] == value).all(1)]["fom"])

Steps to reproduce the problem

effs = p3.metrics.application_efficiency(df)

The warnings go away with:

diff --git a/p3/metrics/_efficiency.py b/p3/metrics/_efficiency.py
index bd7bc88..c18a1ba 100644
--- a/p3/metrics/_efficiency.py
+++ b/p3/metrics/_efficiency.py
@@ -55,14 +55,14 @@ def application_efficiency(df, foms="lower"):
     # Identify the best FOM for each (problem, platform) triple
     key = ["problem", "platform"]
     groups = df[key + ["fom"]].groupby(key)
-    best = groups.agg(min) if foms == "lower" else groups.agg(max)
+    best = groups.agg("min") if foms == "lower" else groups.agg("max")
     best.reset_index(inplace=True)
 
     # Calculate application efficiency
     def app_eff(row):
         value = [row["problem"], row["platform"]]
         fom = float(row["fom"])
-        best_fom = float(best.loc[(best[key] == value).all(1)]["fom"])
+        best_fom = float(best.loc[(best[key] == value).all(1)]["fom"].iloc[0])
         if foms == "lower":
             return 0.0 if numpy.isnan(fom) else (best_fom / fom)
         else:
diff --git a/p3/metrics/_pp.py b/p3/metrics/_pp.py
index 5f6ef5b..2c9039f 100644
--- a/p3/metrics/_pp.py
+++ b/p3/metrics/_pp.py
@@ -86,7 +86,7 @@ def pp(df):
     # Keep only the most efficient (application, platform) results.
     key = ["problem", "platform", "application"]
     groups = df[key + efficiencies].groupby(key)
-    df = groups.agg(max)
+    df = groups.agg("max")
     df.reset_index(inplace=True)
 
     # Add a "did not run" value for applications that did not run

Let me know if PRs are welcome.

Specifications

attrs==23.2.0
contourpy==1.2.1
cssselect==1.2.0
cycler==0.12.1
fonttools==4.51.0
importlib_resources==6.4.0
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
lxml==5.2.1
matplotlib==3.8.4
numpy==1.26.4
-e git+ssh://[email protected]/intel/p3-analysis-library.git@69aaa926b5f20e755852caa9014948134c5ca9f6#egg=p3
packaging==24.0
pandas==2.2.2
pillow==10.3.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
referencing==0.34.0
rpds-py==0.18.0
six==1.16.0
tzdata==2024.1
zipp==3.18.1

@tom91136 tom91136 added the bug Something isn't working label Apr 18, 2024
@Pennycook
Copy link
Contributor

Thanks for reporting this, @tom91136. PRs are definitely welcome, so please feel free to open a PR with the changes.

@Pennycook Pennycook added this to the 1.0.0 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants