Questions tagged [nan]

NaN is an abbreviation for "Not a Number". NaN is sometimes not equal to itself.

NaN (Not a Number) is a value of the numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations. Systematic use of NaNs was introduced by the IEEE 754 floating-point standard in 1985, along with the representation of other non-finite quantities such as infinity.

A common feature of NaN in many programming languages is that NaN is not equal to itself.

4290 questions
1
vote
1 answer

NAN returned when extracting number from JSON

I have a very weird bug turn up in my code. I have a weather forecasting site I am building, it uses geolocation to find the city you reside in and then uses wunderground's API to give you the forecast. The problem is that when you search for a city…
Jake Champion
  • 57
  • 1
  • 8
1
vote
0 answers

I got a NaN error when using the Encog 3.0 library

I have a problem when build an elman recurrent neural network using encog 3.0 library. I got NaN error after few iteration. This is my code in MATLAB : net=newlrn (minmax(usdjpytrain),[4,1], {'logsig', 'purelin'}, 'trainscg', 'learngdm', 'mse');…
Akmal
  • 71
  • 1
  • 2
  • 14
1
vote
5 answers

PHP returning NaN

I have a function that calculates the distance between two GPS coordinates. I then get all the coordinates from the database and loop through them all to get the distance between the current one and the previous one, then add that to an array for…
trentr
  • 157
  • 2
  • 2
  • 8
1
vote
1 answer

Receiving NaN value in Fortran app

I'm developing an Fortran application for numerically solving Boundary Value Problem for second order ODE of the type: -y''+q(x)*y=r(x). In this application I use Gauss-ellimination algorithm to solve the linear system of equations and write the…
vladislavn
  • 388
  • 1
  • 8
  • 20
1
vote
2 answers

isnan strange error

I'm getting a lot of headache with a simple isnan test in my code. I have a 3d vector class with variables x,y,z of type double, and the following function in the header file: #ifdef WIN32 bool IsValid() const {return !_isnan(x) && _finite(x) &&…
Nikita
  • 11
  • 3
1
vote
1 answer

Updating span is ok, updating input results in 'NaN'

I'm converting prices using jquery and a php script that pulls in the latest exchange rate from Yahoo! My update function is working on elements that I can update with .text() (eg span elements) but as soon as I try to set the .val() of my input…
BellamyStudio
  • 771
  • 2
  • 9
  • 22
1
vote
0 answers

Numpy complex128 nan in division

I am trying to understand why I get a warning using numpy's (version 1.24.2) complex128, which I do not get using the built-in complex type: import math, numpy (math.nan)/(1j*math.nan) # (nan+nanj) (math.nan)/numpy.complex128(1j*math.nan) #…
Lukas Lang
  • 400
  • 2
  • 11
1
vote
0 answers

How do I replace NaN-values in my dataset with imputed KNN-values? A part of the values remains as NaN-value

I am working on a water quality dataset. The dataset has the following numerical columns: Water Temperature, Turbidity, Wave Height, Wave Period, Battery Life, Transducer known Before imputing, Water Temperature has 63 missing values. Wave Height…
mrgoat
  • 19
  • 2
1
vote
1 answer

Getting 'undefined' or 'NaN' for data-addval when trying to get is as number in JS

I'm building a simple web game and I've been struggling with a problem for hours. No matter how I try to access the data-addval attribute in my JavaScript code, it always returns 'undefined' or 'NaN' when it should be a number. The issue seems to be…
Alex-GR
  • 13
  • 4
1
vote
1 answer

Fill NaN values based on condition in pandas

I have the below dataframe: data = [['1', 'Construction', '', '01/02/2022', '01/06/2022', '1', 'No'], ['N/A', 'Level Site', 'Construction', '01/02/2022', '01/02/2022', '2', 'No'], ['3', 'Foundation', '', '01/03/2023', '01/06/2023', '1', 'Yes'],['2',…
bcoder
  • 37
  • 6
1
vote
3 answers

How to ignore ranking if the data conatins NaN or Inf in R?

I have a dataframe that contains NaN and Inf. I want to rank the data based on a variable (Q). So, I am using rank(df$Q, ties.method= "first") #> [1] 3 5 6 4 2 9 7 10 8 1 As you can see that even NaN and Inf are also ranked. So, I want to…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
1
vote
2 answers

How to reference a Pandas Column that has a dot in the name and use it with first_valid_index()

I need to find the first valid index of the column 'A.b' that has a dot in its name in the following data frame : import pandas as pd import numpy as np data = { 'A.b': [np.nan, 2, np.nan, 4], 'B': [5, 6, 7, np.nan], 'C. e': ['us',…
1
vote
3 answers

Get row with NaN as well as preceding and following NaN row

I have the following snippet from an example dataframe: df = pd.DataFrame({'location': ['Seattle', np.nan, 'Portland', 'San Francisco'], 'time': ['2022-06-01 12:00:00', '2022-06-01 13:00:00', '2022-06-01 14:00:00', '2022-06-01…
mabiel
  • 95
  • 6
1
vote
1 answer

How to get missing percentages values when scrapping Wikipedia table with Pandas read_html?

When I import a table from a webpage to Python then the column (Population.1) shows as NaN while it is not NaN in the original webpage import requests pop_url = ( …
1
vote
1 answer

How can I add a new column filled with values to a pandas DataFrame without getting NaN values?

I new to Python , I am trying to add new column filled with values but when run the code it shows NaN . df0 = pd.DataFrame ({ 'GOV': [ 'Iraq' , 'Pakistan' , 'UAE' , 'UK' ] , 'CAPITAL' : [ 'Baghdad' , 'Islamabad' , 'DUBAI' , 'LONDON' ], 'POPULATION'…