nan Questions

5

Solved

Consider this code snippet: #include <iostream> #include <string> #include <limits> int main() { std::cout << std::numeric_limits<double>::quiet_NaN(); } When com...
Stomach asked 8/2, 2016 at 13:28

6

Solved

If I calculate the mean of a groupby object and within one of the groups there is a NaN(s) the NaNs are ignored. Even when applying np.mean it is still returning just the mean of all valid numbers....
Kempis asked 9/1, 2019 at 8:42

5

This was my try. For example df = pd.DataFrame({'a':[5,0,1,np.nan], 'b':[np.nan,1,4,3], 'c':[-3,-2,0,0]}) df.dropna(axis=1).max(axis=1,key=abs) Filters out well the NaN values but it gets 0 or n...
Phelan asked 7/12, 2015 at 10:24

15

Solved

I'm using TensorFlow and I modified the tutorial example to take my RGB images. The algorithm works flawlessly out of the box on the new image set, until suddenly (still converging, it's around 92...
Pedigree asked 14/11, 2015 at 19:1

1

Solved

This question is very similar to filtering np.nan values from pytorch in a -Dimensional tensor. The difference is that I want to apply the same concept to tensors of 2 or higher dimensions. I have ...
Winola asked 29/10, 2020 at 15:42

4

Solved

I need a function that returns non-NaN values from an array. Currently I am doing it this way: >>> a = np.array([np.nan, 1, 2]) >>> a array([ NaN, 1., 2.]) >>> np.inver...
Bonacci asked 14/5, 2010 at 2:30

3

Solved

I have to remove both nan and inf values from two arrays. I found this post useful https://mcmap.net/q/989185/-pearson-correlation-and-nan-values for removing nan. Is there any similar solution whe...
Mendicant asked 15/6, 2018 at 13:16

5

Solved

Is this possible to assign a NaN to a double or float in C/C++? Like in JavaScript you do: a = NaN. So later you can check if the variable is a number or no.
Acapulco asked 22/5, 2013 at 12:1

7

Solved

I have a double in Java and I want to check if it is NaN. What is the best way to do this?
Gillam asked 21/9, 2009 at 20:9

2

I'm trying to create a new column from 4 multiple columns that start with the same name. Either 3 or 4 out of these columns are NaN. I'd like to have the new column to have this non-NaN value, if i...
Orthoptic asked 22/9, 2020 at 10:40

6

Solved

What is the best way to account for (not a number) nan values in a pandas DataFrame? The following code: import numpy as np import pandas as pd dfd = pd.DataFrame([1, np.nan, 3, 3, 3, np.nan], co...
Rush asked 30/12, 2015 at 20:50

6

Solved

I would like to check a tensorflow variable and set it to zero if it is NaN. How can I do this? The following trick seems not to work: if tf.is_nan(v) is True: v = 0.0
Ventilation asked 25/8, 2017 at 2:17

3

Solved

I'm trying to calculate the entropy of the weights while training my graph and to use it for regularization. This of course involves w*tf.log(w), and as my weights are changing some of them are bou...
Demello asked 22/7, 2016 at 13:28

3

Solved

I’m slightly disappointed that np.inf // 2 evaluates to np.nan and not to np.inf, as is the case for normal division. Is there a reason I’m missing why nan is a better choice than inf?
Mellie asked 11/8, 2020 at 17:6

3

I know that IEEE 754 defines NaNs to have the following bitwise representation: The sign bit can be either 0 or 1 The exponent field contains all 1 bits Some bits of the mantissa are used to spec...
Wasteful asked 28/11, 2015 at 4:47

2

Could you guys please help me explain the code below: Why a nan is not np.nan? import pandas as pd import numpy as np df.iloc[31464]['SalesPersonID'] [out]: nan df.iloc[31464]['SalesPersonI...
Pondweed asked 22/8, 2020 at 3:6

3

Solved

After reading in an excel sheet with a MultiIndex, I am getting np.nan appearing in the index because some of the values are 'N/A' and pd.read_excel thinks it's a good idea to convert them. However...
Labor asked 15/9, 2016 at 2:45

4

Solved

I'm writing a ray tracer and part of the process is firing a ray that may or may not hit an object (geometric object). A number of the equations that describe objects return NaN naturally if no int...
Flavin asked 7/12, 2012 at 8:52

2

I'm using the SLSQP solver in scipy.minimize to solve a constrained optimization problem. Very often the solver will try parameter values that violate the constraints. When these constraints are vi...
Eraeradiate asked 24/3, 2018 at 4:42

2

Solved

I'm a bit stumped by how scipy.spatial.distance.pdist handles missing (nan) values. So just in case I messed up the dimensions of my matrix, let's get that out of the way. From the docs: The po...
Carpathoukraine asked 16/7, 2014 at 13:0

1

Solved

If I have an array with nan, which looks like this: array([[ 0., 0., 0., 0.], [ 0., 0., nan, nan], [ 0., 1., 3., nan], [ 0., 2., 4., 7.], [ 0., nan, 2., nan], [ 0., 4., nan, nan]]) how ...
Meggs asked 22/7, 2020 at 9:44

4

Solved

Is there a direct way to create a mask where values in a cv::Mat_<double> are compared against NAN? cv::Mat_<real> mat = ... cv::Mat_<uchar> mask = (mat == NAN); does not work ...
Ultraconservative asked 20/1, 2017 at 8:36

3

Solved

I have a dataframe like this df = (pd.DataFrame({'ID': ['ID1', 'ID2', 'ID3'], 'colA': ['A', 'B', 'C'], 'colB': ['D', np.nan, 'E']})) df ID colA colB 0 ID1 A D 1 ID2 B NaN 2 ID3 C E I want...
Tyrannicide asked 19/7, 2019 at 12:17

1

Solved

How does C++ treat floating-point NaN when doing space-ship comparison operations? We know that the usual compares always return false, so how does this change with NaN? std::numeric_limits<doub...
Emden asked 30/6, 2020 at 0:7

2

Solved

> import numpy as np > min(50, np.NaN) 50 > min(np.NaN, 50) nan (Same behaviour occurs with max) I know that I can avoid this behaviour by using numpy.nanmin. But what causes the ...
Shawntashawwal asked 29/6, 2020 at 11:11

© 2022 - 2024 — McMap. All rights reserved.