Construct an array with Nan elements

0 votes
I do not know how to construct an array with some Nan elements and other float elements. Can someone share a code for this requirement?
Jul 15, 2019 in Python by Kirti
1,077 views

1 answer to this question.

0 votes

Create a numpy array with nan value and float values and print all the values in the array which are not nan,

import numpy
a = numpy.array([numpy.nan, 1,2,numpy.nan,3,4,5])
print(a)
print(a[~numpy.isnan(a)])
answered Jul 15, 2019 by Yogi

Related Questions In Python

0 votes
1 answer

Is it possible to create an array with all values as zero in python?

You can use  np.zeros(4,3) This will create a 4 ...READ MORE

answered May 24, 2019 in Python by Anjali
206 views
0 votes
1 answer

Reconstruct an array by replacing every element with a[[i-1]%K] - Python

Hey varsha, Have a look at this ...READ MORE

answered Jun 14, 2019 in Python by Miya
483 views
0 votes
1 answer

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Hello @kartik, Since different users might have different ...READ MORE

answered Jun 15, 2020 in Python by Niroj
• 82,560 points
9,848 views
0 votes
0 answers

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I couldn't figure out the problem. here my ...READ MORE

Dec 17, 2020 in Python by muammer
• 120 points
384 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,840 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,419 views
0 votes
1 answer

Is an array a view of another?

The array has a base attribute, as ...READ MORE

answered Apr 23, 2019 in Python by SDeb
• 13,250 points
95 views
0 votes
1 answer

Python code to send an email with an attachment

Hi @Vipul, try out this code. I've ...READ MORE

answered Jun 11, 2019 in Python by Adil
9,470 views