Module 4 - 1
Module 4 - 1
Extract data from the given CSV file and store the data from each column in a
separate NumPy array
import pandas
import numpy
N=1
y = pandas.read_csv('F:/Usman/FairDealCustomerDatanew.csv')
z=set(numpy.array(y.name))
m=set(numpy.array(y.Location))
print(z)
print(m)
6. Create a numpy array [[0, 1, 2], [ 3, 4, 5], [ 6, 7, 8],[ 9, 10, 11]]) and
filter the elements greater than 5.
import numpy
z=t.ravel()
m=[]
for i in range(12):
if i>5:
m.append(i)
print(m)
8. Create a 10x10 array with random values and find the minimum and maximum values.
import pandas
import numpy
t=numpy.random.random((10,10))
m=t.ravel()
f=m.max()
n=m.min()
print(f,n)
import pandas
import numpy
y=numpy.arange(1,31)
x=0
for i in range(30):
x=x+i
10. Create numpy array having elements 0 to 10 And negate all the elements between
3 and 9
import numpy
y=numpy.arange(0,10)
x=[]
for i in range(3,9):
x.append(i*-1)
import numpy
11. Create a random array of 3 rows and 3 columns and sort it according to 1st
column, 2nd column or 3rd column.
rand = numpy.random.RandomState(42)
X = rand.randint(0, 10, (4, 6))
y=numpy.sort(X,axis=0)
y=numpy.sort(X,axis=1)
print(X)
12. Create a four dimensions array get sum over the last two axis at once
import numpy
rand = numpy.random.RandomState(42)
X = rand.randint(0, 10, (4, 6))
y=numpy.sort(X,axis=0)
y=numpy.sort(X,axis=1)
z=numpy.sum(X)
print(z)
print(y)