I am collecting some data from a database and adding them together to get some statistics, but since I backdate some of my data then the calculated sum will sometime come up as NaN
(not a number) I want to create an if sentence that says if(not a number) then exclude this data from my table.
How do I test if the data (in this case double) is NaN
?
You can replace the missing value ( NaN ) in pandas. DataFrame and Series with any value using the fillna() method.
Detect missing values for an array-like object. This function takes a scalar or array-like object and indicates whether values are missing ( NaN in numeric arrays, None or NaN in object arrays, NaT in datetimelike).
The pandas. DataFrame. duplicated() method is used to find duplicate rows in a DataFrame. It returns a boolean series which identifies whether a row is duplicate or unique.
There are static methods Float.isNaN(float)
and Double.isNaN(double)
that you can use.
double x = ... // whatever calculation you do
if (Double.isNaN(x)) {
...
}
You can test for NaN two ways. You can use the built in function
Double.isNaN(x)
or perform the check this does which is
if (x != x)
provided x is a double
or a float
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With