Skip to content

BUG: invalidate cached Index._isnan if use_inf_as_na changed? #44262

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

Closed
3 tasks done
jbrockmendel opened this issue Nov 1, 2021 · 4 comments
Closed
3 tasks done

BUG: invalidate cached Index._isnan if use_inf_as_na changed? #44262

jbrockmendel opened this issue Nov 1, 2021 · 4 comments
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Nov 1, 2021

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

import numpy as np
import pandas as pd

idx = pd.Index([np.inf, np.nan], dtype=np.float64)

assert (pd.isna(idx) == idx.isna()).all()

pd.set_option("use_inf_as_na", True)

assert (pd.isna(idx) == idx.isna()).all()  # <- nope!

Issue Description

pd.isna(obj) and obj.isna() are generally interchangeable, but pd.Index caches .isna in a _isnan cache_readonly. If we want to maintain that interchangeability, we'd need to invalidate that cache.

My inclination is that it isn't worth futzing around with, but someone who uses use_inf_as_na=True might care more.

Expected Behavior

assert (pd.isna(idx) == idx.isna()).all()

Installed Versions

Replace this line with the output of pd.show_versions()

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 1, 2021
@mroeschke
Copy link
Member

Just a heads up: some of your issues have examples have an extra ``` at the bottom of the formatting block which messes up the rendering of the issue

@jbrockmendel
Copy link
Member Author

Thanks; still getting used to the new templates.

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 1, 2021
@jreback jreback added this to the 1.4 milestone Nov 1, 2021
@simonjayhawkins
Copy link
Member

removing milestone

@simonjayhawkins simonjayhawkins removed this from the 1.4 milestone Jan 20, 2022
@jbrockmendel
Copy link
Member Author

#53494 deprecated use_inf_as_na, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

4 participants