A[A==NDV]=numpy.nan

A==NDV will produce a boolean array that can be used as an index for A

Answer from Paul on Stack Overflow
🌐
NumPy
numpy.org › doc › 2.3 › reference › constants.html
Constants — NumPy v2.3 Manual
numpy.nan# IEEE 754 floating point representation of Not a Number (NaN). Returns · y : A floating point representation of Not a Number. See Also · isnan : Shows which elements are Not a Number. isfinite : Shows which elements are finite (not one of Not a Number, positive infinity and negative ...
People also ask

Is np.nan a float?
Yes. np.nan is a floating-point value, so including it in a NumPy array of integers causes the array to use a floating-point dtype.
🌐
askpython.com
askpython.com › python › examples › nan-in-numpy-and-pandas
Understanding np.nan in NumPy and Pandas - AskPython
What does np.nan do?
np.nan is a floating-point NaN value used to mark an unavailable numeric entry. Use np.isnan to detect it in a NumPy array.
🌐
askpython.com
askpython.com › python › examples › nan-in-numpy-and-pandas
Understanding np.nan in NumPy and Pandas - AskPython
Can I sum an array that contains np.nan?
Yes, but a regular NumPy sum returns NaN when a NaN participates. Use np.nansum only when ignoring missing entries is valid for the calculation.
🌐
askpython.com
askpython.com › python › examples › nan-in-numpy-and-pandas
Understanding np.nan in NumPy and Pandas - AskPython
🌐
NumPy
numpy.org › doc › stable › reference › constants.html
Constants — NumPy v2.5 Manual
numpy.nan# IEEE 754 floating point representation of Not a Number (NaN). Returns · y : A floating point representation of Not a Number. See Also · isnan : Shows which elements are Not a Number. isfinite : Shows which elements are finite (not one of Not a Number, positive infinity and negative ...
🌐
AskPython
askpython.com › python › examples › nan-in-numpy-and-pandas
Understanding np.nan in NumPy and Pandas - AskPython
September 30, 2026 - Use the mask to select, replace or count those entries. NumPy documents the same rule in its missing-value guidance, which recommends isnan instead of equality. NaN propagates through ordinary arithmetic because the result depends on a value that is unknown.
🌐
Interactive Chaos
interactivechaos.com › en › python › function › numpynan
numpy.nan | Interactive Chaos
January 16, 2021 - numpy.nan · Library · NumPy · Syntax · numpy.nan · Description · numpy.nan is a special value from the NumPy library that represents the null value. Parameters · numpy.nan does not accept arguments. Result · numpy.nan returns a value of type float. Examples · We can create a NumPy ...
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Replace NaN (np.nan) using np.nan_to_num() and np.isnan() | note.nkmk.me
January 23, 2024 - If you want to generate NaN explicitly, use np.nan or float('nan'). You can also import the math module of the standard library and use math.nan.
🌐
NumPy
numpy.org › doc › stable › user › misc.html
Miscellaneous — NumPy v2.5 Manual
>>> myarr = np.array([1., 0., np.nan, 3.]) >>> np.nonzero(myarr == np.nan) (array([], dtype=int64),)
Find elsewhere
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.nan_to_num.html
numpy.nan_to_num — NumPy v2.5 Manual
Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords.
🌐
NumPy
numpy.org › devdocs › reference › constants.html
Constants — NumPy v2.6.dev0 Manual
numpy.nan# IEEE 754 floating point representation of Not a Number (NaN). Returns · y : A floating point representation of Not a Number. See Also · isnan : Shows which elements are Not a Number. isfinite : Shows which elements are finite (not one of Not a Number, positive infinity and negative ...
🌐
Reintech
reintech.io › blog › handling-missing-data-nan-values-numpy
Handling Missing Data and NaN Values in NumPy - Reintech
June 13, 2026 - NumPy uses IEEE 754 floating-point special value np.nan to represent missing or undefined numerical data.
🌐
Appdividend
appdividend.com › np-nan
Numpy.nan (np.nan) in Python
July 11, 2025 - The np.nan is a special floating-point constant defined in the NumPy library that represents "Not a Number" (NaN).
🌐
Python Guides
pythonguides.com › python-numpy-nan
How NumPy Create NaN Array in Python?
May 16, 2025 - Let’s look at a practical example where NaN arrays are essential. Imagine we’re analyzing stock market data for the top 5 tech companies, but we’re missing data for some days: import numpy as np import pandas as pd import matplotlib.pyplot as plt # Stock tickers for top tech companies tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'META'] # Create a 5x7 array for a week of stock prices (with missing data) stock_data = np.full((5, 7), np.nan) # Fill in some known values (simulated data) stock_data[0, :5] = [150.2, 151.3, 149.8, 152.0, 153.5] # AAPL (missing weekend) stock_data[1, :] = [290.1
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.nan_to_num.html
numpy.nan_to_num — NumPy v2.1 Manual
Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › numpy tutorial › numpy nan
NumPy NaN | Working of NumPy NaN in Python with Examples
April 19, 2023 - In Python, NumPy NAN stands for not a number and is defined as a substitute for declaring value which are numerical values that are missing values in an array as NumPy is used to deal with arrays in Python and this can be initialized using numpy.nan ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.1 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'># Test element-wise for NaN and return result as a boolean array.
🌐
Note.nkmk.me
note.nkmk.me › home › python
What is nan in Python (float('nan'), math.nan, np.nan) | note.nkmk.me
May 9, 2023 - In addition, nan is defined in math (standard library) and NumPy; both NaN and NAN are defined as aliases in NumPy.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Remove NaN (np.nan) from an array | note.nkmk.me
January 23, 2024 - You can use np.isnan() to check if values in an ndarray are NaN.
🌐
Saturn Cloud
saturncloud.io › blog › efficiently-checking-if-arbitrary-object-is-nan-in-python-numpy-pandas
Efficiently Checking if Arbitrary Object is NaN in Python Numpy and Pandas | Saturn Cloud Blog
May 1, 2026 - In NumPy, the nan_to_num() function can be used to replace NaN values with a specified value. In Pandas, the isna() function can be used to check for NaN values in a DataFrame or Series, and the fillna() function can be used to replace NaN values ...