nan Questions
3
I'm using Python 3.4.1 with numpy 0.10.1 and pandas 0.17.0. I have a large dataframe that lists species and gender of individual animals. It's a real-world dataset and there are, inevitably, missin...
3
I want to drop all NaN variables in one of my columns but when I use df.dropna(axis=0, inplace=True) it erases my entire dataframe. Why is this happening?
I've used both df.dropna and df.dropna(a...
Darkling asked 3/4, 2019 at 14:53
1
Nice evening everyone,
i spent the last 6 hours trying to debug seemingly randomly occuring NaN-values in Jax.
I have narrowed down that the NaNs initially stem from either the loss-function or its...
Chiliad asked 21/11, 2021 at 18:20
3
Solved
As per the title here's a reproducible example:
raw_data = {'x': ['this', 'that', 'this', 'that', 'this'],
np.nan: [np.nan, np.nan, np.nan, np.nan, np.nan],
'y': [np.nan, np.nan, np.nan, np.nan...
3
Solved
I have a dataframe which contains nan values at few places. I am trying to perform data cleaning in which I fill the nan values with mean of it's previous five instances. To do so, I have come up w...
5
Solved
I'm trying to test if one of my variables is pd.NaT. I know it is NaT, and still it won't pass the test. As an example, the following code prints nothing :
a=pd.NaT
if a == pd.NaT:
print("a not ...
Subsidiary asked 22/3, 2018 at 17:49
5
Solved
I am trying to run some trading strategies in R. I have downloaded some stock prices and calculated returns. The new return dataset has a number of -inf, NaN, and NA values. I am reproducing a row ...
Finned asked 22/6, 2015 at 22:34
1
Solved
How do I consolidate/reduce a DataFrame so that it merges rows by custom column 'id' and puts values into a list if they are not Nan. So far I came up with this but it doesn't remove Nans:
x: pd.Da...
Mcshane asked 10/1, 2022 at 9:55
2
Solved
I have a dataframe with some NaN values.
Here is a sample dataframe:
sample_df = pd.DataFrame([[1,np.nan,1],[2,2,np.nan], [np.nan, 3, 3], [4,4,4],[np.nan,np.nan,5], [6,np.nan,np.nan]])
It look...
2
Solved
When I use .Internal(inspect()) to NA_real_ and NaN, it returns,
> .Internal(inspect(NA_real_))
@0x000001e79724d0e0 14 REALSXP g0c1 [REF(2)] (len=1, tl=0) nan
> .Internal(inspect(NaN))
@0x000...
1
Solved
I'm trying to create a function to check the quality of data (nans/nulls etc)
I have the following code running on a PySpark DataFrame
df.select([f.count(f.when((f.isnan(c) | f.col(c).isNull()), c)...
Shoeshine asked 23/12, 2021 at 7:7
1
Solved
I have a large dataset that is one huge table that actually should be many tables. The headers are buried in the rows for the subsets.
My goal is to pull those headers out into a new column such th...
8
Solved
sorted([2, float('nan'), 1]) returns [2, nan, 1]
(At least on Activestate Python 3.1 implementation.)
I understand nan is a weird object, so I wouldn't be surprised if it shows up in random place...
3
Solved
I have a DataFrame:
name
age
0
Paul
25
1
John
27
2
Bill
23
I know that if I enter:
df[['name']] = df[['age']]
I'll get the following:
name
age
0
25
25
1
27
27
2
23
...
5
Solved
When summing two pandas columns, I want to ignore nan-values when one of the two columns is a float. However when nan appears in both columns, I want to keep nan in the output (instead of 0.0).
In...
5
Solved
I have 2 nullable doubles, an expected value and an actual value (let's call them value and valueExpected). A percentage is found using 100 * (value / valueExpected). However, if valueExpected is z...
2
Solved
I have an array with floats and NaNs yet when I call numpy.nanmean() on the array I get NaNas result. How is this possible?
This is a sample of the array ages
[22.0 38.0 26.0 35.0 35.0 nan 54.0 2...
Snorter asked 31/5, 2016 at 20:21
3
Solved
I would like to compile a program with gfortran and -O3 -ffast-math enabled, since it gives a nice performance boost. I was rather confused, that gfortran's isnan() catched some NaN's but not all o...
Firearm asked 11/4, 2013 at 8:59
25
Solved
In JavaScript, why does isNaN(" ") evaluate to false, but isNaN(" x") evaluate to true?
I’m performing numerical operations on a text input field, and I’m checking if the field is null, "", or NaN...
Aguilar asked 5/5, 2009 at 15:21
8
Solved
I'm looking for the fastest way to check for the occurrence of NaN (np.nan) in a NumPy array X. np.isnan(X) is out of the question, since it builds a boolean array of shape X.shape, which is potent...
Luxembourg asked 18/7, 2011 at 17:10
5
Solved
I would like to know if there is a clean way to handle nan in numpy.
my_array1=np.array([5,4,2,2,4,np.nan,np.nan,6])
print my_array1
#[ 5. 4. 2. 2. 4. nan nan 6.]
print set(my_array1)
#set([nan, n...
12
Solved
I've got a pandas DataFrame filled mostly with real numbers, but there is a few nan values in it as well.
How can I replace the nans with averages of columns where they are?
This question is very...
1
Solved
Why is math.nan different than numpy.nan?
>>> import math
>>> import numpy as np
>>> math.nan is math.nan
True
>>> np.nan is np.nan
True
>>> np.nan is m...
Freeholder asked 5/7, 2021 at 12:20
1
Solved
I got this 2D numpy array with missing values. Is there a simple (and reasonably fast) way of filling the nan values with the closest (preferably euclidean distance, but manhattan is ok too) non-na...
3
Solved
I'm trying to check if a variable I have is equals to NaN in my Ruby on Rails application.
I saw this answer, but it's not really useful because in my code I want to return 0 if the variable is Na...
© 2022 - 2024 — McMap. All rights reserved.