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 in Python by Kirti
20 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 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 in Python by Anjali
66 views
0 votes
1 answer
+4 votes
7 answers
0 votes
1 answer
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 399 views
+4 votes
6 answers
0 votes
1 answer

Is an array a view of another?

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

answered Apr 23 in Python by SDeb
• 13,210 points
32 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 in Python by Adil
396 views