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

[BUG] cuDF covariance does not agree with pandas when ddof=N #10303

Open
bdice opened this issue Feb 16, 2022 · 3 comments
Open

[BUG] cuDF covariance does not agree with pandas when ddof=N #10303

bdice opened this issue Feb 16, 2022 · 3 comments
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@bdice
Copy link
Contributor

bdice commented Feb 16, 2022

In PR #9889, @isVoid observed that cudf and pandas handle covariance calculations differently when N == ddof. Here is a minimal example showing a few differences in behavior with ddof. This is a bug because cudf should give the same results as pandas. The bug affects both df.cov() and df.groupby(...).cov(). Note that this is not related to the pandas bug 45814 which was also found during #9889 (not directly linked here because it is not related) regarding ddof with missing data, because no data is missing here.

import pandas as pd
import cudf

pdf = pd.DataFrame({"i": [0, 0], "a": [0, 1]})
gdf = cudf.from_pandas(pdf)
print("pandas cov")
print(pdf.cov(ddof=2))
print("cudf cov")
print(gdf.cov(ddof=2))
print("pandas groupby cov")
print(pdf.groupby("i").cov(ddof=2))
print("cudf groupby cov")
print(gdf.groupby("i").cov(ddof=2))

Results (warnings not shown):

pandas cov                                                                                                                                                                                    
    i    a
i NaN  NaN
a NaN  inf

cudf cov
     i    a
i  0.0  0.0
a  0.0  0.5

pandas groupby cov
       a
i       
0 a  inf

cudf groupby cov
        a
i        
0 a  <NA>

Notice that cudf isn't self-consistent between df.cov() and df.groupby(...).cov() in its results for a.

Originally posted by @bdice in #9889 (comment)

@bdice bdice changed the title cuDF covariance does not agree with pandas when ddof=N [BUG] cuDF covariance does not agree with pandas when ddof=N Feb 16, 2022
@bdice bdice added bug Something isn't working Python Affects Python cuDF API. labels Feb 16, 2022
@rapids-bot rapids-bot bot closed this as completed in fe37c0e Feb 17, 2022
@isVoid isVoid reopened this Feb 17, 2022
@isVoid
Copy link
Contributor

isVoid commented Feb 17, 2022

This was accidentally closed because my comment here: #9889 (review)

@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
Status: Todo
Development

No branches or pull requests

4 participants