nan

Image Processing Issue: Fill NaNs in image, which mostly consists of NaNs

僤鯓⒐⒋嵵緔 提交于 2019-12-06 13:41:57
问题 I have a dataset / image DD like the one in this image: (by the way: is there a way of uploading small data sets here, so that you can actually work with the same data I use, without having to put them in the code?) Colored pixels in the image represent height/depth ranging from 0 to about 400 meters. Blue pixels are NaN . Now what I need to do is to interpolate the pixel values WITHIN the displayed object, but without interpolating the whole image. I tried using the function inpaint_nans

NaNs produced in deSolve package

跟風遠走 提交于 2019-12-06 12:14:17
I have got a system of 8 differential equations that I am trying to solve using deSolve in R. It just returns NaN after the first few steps and doesn't solve it further. I tried various differential solvers like lsoda (default), bdf , adams , rk4 etc, but it didn't help. Here is the sample R code: library(deSolve) daero = c(5.29,4.16,2.49,1.53,0.7,0.41,0.21)*10^-4 rho = rep(1.27,7) dgeo = daero * sqrt(1/rho) r0 = dgeo/2 Fr = c(0.188,0.297,0.274,0.181,0.032,0.013,0.015) X0 = Fr*200*10^-6 N0 = X0*(3/(4*3.14*r0^3*rho)) func1 <- function(t,state,parameters){ with(as.list(c(state,parameters)),{ dX1

How to convert signalling NaN to quiet NaN?

删除回忆录丶 提交于 2019-12-06 08:41:49
I want to convert signalling NaN to quiet NaN in C. Could anybody suggest a method? Thanks. I guess I'll expand on my comment and provide a solution. The tricky part here is being able to read/compare the sNaN without triggering an exception. After all it's called "signalling" for a reason. Wikipedia says that even comparison operations on sNaN will trigger an exception. So a direct use of number != number or isnan(value) probably don't work because they invoke comparisons and will trigger a hardware exception. (I'm not entirely sure how isnan(value) is implemented though.) EDIT : Correction,

zero values of an array to be converted to nan values

安稳与你 提交于 2019-12-06 05:50:16
问题 I have an array 1200*1200. Some of its values are zero. I want to convert the zero values to numpy.nan values. This is my solution: import numpy for i in range(1200): for j in range(1200): if data_a[i, j] == 0: data_a[i, j] = numpy.nan But I got this error: data_a[i,j] = numpy.nan ValueError: cannot convert float NaN to integer I don't understand the error. Any alternatives or solutions? 回答1: That error message is because your array is for storing integers: >>> import numpy as np >>> a = np

NaN Values in a float field in MSSQL Database

时光总嘲笑我的痴心妄想 提交于 2019-12-06 05:39:40
问题 I am working on an old database I inherited from my predecessors. In it, some float fields contains NaN where there should be a null. The following SQL doesn't work because it doesn't recognize NaN. UPDATE xxx SET column= null WHERE column=NaN How can I do this? 回答1: Try UPDATE xxx SET column= null WHERE IsNumeric(column)=0 Then run your select again. 来源: https://stackoverflow.com/questions/450618/nan-values-in-a-float-field-in-mssql-database

Remove NaN row from X array and also the corresponding row in Y

跟風遠走 提交于 2019-12-06 03:04:25
问题 I have an X array with NaN and I can remove the row with NaN as such: import numpy as np x = x[~np.isnan(x)] But I have a corresponding Y array assert len(x) == len(y) # True x = x[~np.isnan(x)] assert len(x) == len(y) # False and breaks How do I remove the corresponding rows from the Y array? My X array looks like this: >>> x [[ 2.67510434 2.67521927 3.49296989 3.80100625 4. 2.83631844] [ 3.47538057 3.4752436 3.62245715 4.0720535 5. 3.7773169 ] [ 2.6157049 2.61583852 3.48335887 3.78088813 0.

Error when plotting DataFrame containing NaN with Pandas 0.12.0 and Matplotlib 1.3.1 on Python 3.3.2

元气小坏坏 提交于 2019-12-06 01:54:27
问题 First of all, this question is not the same as this one. The problem I'm having is that when I try to plot a DataFrame which contains a numpy NaN in one cell, I get an error: C:\>\Python33x86\python.exe Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pandas as pd >>> import numpy as np >>> import matplotlib.pyplot as plt >>> >>> dates = pd.date_range('20131201',

Assigning using += gives NaN in javascript

六月ゝ 毕业季﹏ 提交于 2019-12-06 01:22:24
Assignment a number to an attribute using the += operator gives me NaN in JavaScript. This code works as expected: > var result = {}; undefined > result['value'] = 10; 10 > result['value'] += 10; 20 But here we get NaN : > var test = {}; undefined > test['value'] += 10; NaN Why does JavaScript behave like this? How can I get this to work without initializing result['value'] = 0 ? Blazemonger You can't add a number to undefined in JavaScript. If you don't want to initialize the number, you need to test if it's undefined before incrementing it: test['value'] = (typeof test['value']==='undefined'

Pandas replace nan with mean value for a given grouping

删除回忆录丶 提交于 2019-12-06 00:27:48
I have a large dataset of the form: period_id gic_subindustry_id operating_mgn_fym5 operating_mgn_fym4 317 201509 25101010 13.348150 11.745965 682 201509 20101010 10.228725 10.473917 903 201509 20101010 NaN 17.700966 1057 201509 50101010 27.858305 28.378040 1222 201509 25502020 15.598956 11.658813 2195 201508 25502020 27.688324 22.969760 2439 201508 45202020 NaN 27.145216 2946 201508 45102020 17.956425 18.327724 In practice, I have thousands of values for each year going back 25 years, and multiple (10+) columns. I am trying to replace the NaN values with the gic_industry_id median/mean value

Summing rows in grouped pandas dataframe and return NaN

可紊 提交于 2019-12-05 23:13:22
问题 Example import pandas as pd import numpy as np d = {'l': ['left', 'right', 'left', 'right', 'left', 'right'], 'r': ['right', 'left', 'right', 'left', 'right', 'left'], 'v': [-1, 1, -1, 1, -1, np.nan]} df = pd.DataFrame(d) Problem When a grouped dataframe contains a value of np.NaN I want the grouped sum to be NaN as is given by the skipna=False flag for pd.Series.sum and also pd.DataFrame.sum however, this In [235]: df.v.sum(skipna=False) Out[235]: nan However, this behavior is not reflected