Skip to content

BUG: histogram weights aren't dropped if NaN values in data #48888

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

Merged
merged 40 commits into from
Jan 3, 2023

Conversation

AdamOrmondroyd
Copy link
Contributor

@AdamOrmondroyd AdamOrmondroyd commented Sep 30, 2022

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thx for this. Could you please add tests?

@AdamOrmondroyd
Copy link
Contributor Author

I've created a test where a df and set of weights are made, and one value in each column of df is set to NaN. I then make a copy of the df without the NaNs, and copies of weights with the corresponding weights dropped. It then checks that histograms made using each pair have the same heights.

@mroeschke mroeschke added the Visualization plotting label Oct 3, 2022
kwds["weights"] = weights[:, i]
if weights is not None:
if np.ndim(weights) != 1:
weights = weights[:, i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if i is out of bounds?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is still open, otherwise lgtm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ormorod doesn't look like this was addressed. Can i be out of bounds?

@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Dec 28, 2022
@AdamOrmondroyd
Copy link
Contributor Author

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

Will merge main now. I addressed the comments above but haven't had a response.

@mroeschke mroeschke reopened this Dec 28, 2022
@AdamOrmondroyd
Copy link
Contributor Author

It also occurs to me that weights itself might work better as a dict or DataFrame if it has more than a single column, but I think this is beyond the scope of this PR

@mroeschke mroeschke added this to the 2.0 milestone Jan 3, 2023
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM merge when ready @phofl

@phofl phofl merged commit 41ab44a into pandas-dev:main Jan 3, 2023
@phofl
Copy link
Member

phofl commented Jan 3, 2023

Thx @Ormorod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: histogram weights aren't dropped if NaN values in data
3 participants