Posted by: Sourav | July 10, 2017

Basic Numpy operations in Python,Python teacher Sourav,Kolkata 09748184075


import numpy as np
create a rank 1 array

l=[[1,2],[4,5],[3,6]]
l=[[1,2],[3,6],[4,5]]
l=[[1,2],[4,5],[3,6]]

##print type(l)
k=[3,6,1,80,0,4]

if type(l) is list:
print ‘l is a list’

sortelem=[]
for elem in l:
if type(elem) is list and len(elem)>0:
sortelem.append(elem[0])

##print sortelem
sortelem.sort()

print sortelem
index
for i in range(0,len(sortelem)):
for j in range(0,len(l):
if sortelem[i]=l
##
l.sort(key=lambda l:l[1])
print l

 

x=np.array([2,4,3,1])
print x

print type(x)

print x.shape

x[0]=102

print x

 

y=np.array([[4,5,6],[5,2,7]])
print y

print type(y)

print y.shape

 

w=np.zeros((3,3))
print w

print w.shape

w=np.ones((3,3))
print w

w=np.full((4,4),10,dtype=np.int64)

print w

r=(np.random.random((5,5)))

print r

 

i=np.eye(4,4)

print i

list1=[4,6,7,2,10]
f=np.array(list1)
print type(f)

 

g=np.arange(20)

print g

print g.shape

 

h=np.array([[0,1,2,0],[0,1,2],(4+5j,10,25)])

print h[0]

floatarray=np.arange(1,20,dtype=np.float64)

print floatarray

 

j=np.linspace(0,100,10,dtype=np.longdouble)

print j

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: