0% found this document useful (0 votes)
3 views2 pages

Assignment 2

The document contains a series of Python code assignments involving data manipulation and analysis using libraries such as NumPy, Pandas, and SciPy. It covers tasks like calculating maximum and minimum values, distances between points, statistical measures like mean and IQR, and visualizing data with histograms. Additionally, it includes operations on a dataset from the Iris flower dataset, demonstrating data reading and basic statistical analysis.

Uploaded by

sahilbro8698
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Assignment 2

The document contains a series of Python code assignments involving data manipulation and analysis using libraries such as NumPy, Pandas, and SciPy. It covers tasks like calculating maximum and minimum values, distances between points, statistical measures like mean and IQR, and visualizing data with histograms. Additionally, it includes operations on a dataset from the Iris flower dataset, demonstrating data reading and basic statistical analysis.

Uploaded by

sahilbro8698
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment2

Set-A

Q1)
import numpy as n
d=n.array([[0,1],[2,3]])
print(d.max())
print(d.min())

Q2)
import numpy
point_a = numpy.array((10, 20, 30))
point_b = numpy.array((4, 5, 6))

dist = numpy.linalg.norm(point_a-point_b)
print(dist)

Q3)
import pandas as p
import statistics as s
import numpy as n
df=p.DataFrame([3,4,1,9,20,1,23,45,56,23,43,54])
print("mean==",df.mean())
range=df.max()-df.min()
print("Range is ==",range)
q3,q1=n.percentile(df,[75,25])
iqr=q3-q1
print("iqr==",iqr)

Q4)
from scipy.spatial.distance import cityblock
import pandas as pd

#define DataFrame
df = pd.DataFrame({'A': [2, 4, 4, 6],
'B': [5, 5, 7, 8],
'C': [9, 12, 12, 13]})

#calculate Manhattan distance between columns A and B


cityblock(df.A, df.B)

Q5)
import numpy as np
import matplotlib.pyplot as plt
nums = np.array([0.5, 0.7, 1.0, 1.2, 1.3, 2.1])
bins = np.array([0, 1, 2, 3])
print("nums: ",nums)()
print("bins: ",bins)
print("Result:", np.histogram(nums, bins)) #np.histogram function has
two return values hist which gives the array of values of the
histogram, and edge_bin which is an array of float datatypes
containing the bin edges having length one more than the hist.
plt.hist(nums, bins=bins)
plt.show()
Q6)
import pandas as p
d=p.DataFrame({'name':['kunal','rekha','satish','ashish','radha'],
'age':[20,23,22,20,21],
'per':[98,80,95,92,85]})
print("average of age",d['age'].mean())
print("average of percentage",d['per'].mean())
d.describe()

SETB

Q1)import pandas as p
d=p.read_csv('C:\\Users\\DELL\\Untitled Folder\\Iris.csv')
d.sample(20)
print(" MAx Id==",d['Id'].max())
print(d['SepalLengthCm'].max())
print(d['SepalWidthCm'].max())
print(d['PetalLengthCm'].max())
print(d['PetalWidthCm'].max())

print("Min Id==",d['Id'].min())
print(d['SepalLengthCm'].min())
print(d['SepalWidthCm'].min())
print(d['PetalLengthCm'].min())
print(d['PetalWidthCm'].min())

Q3)
import pandas as p
d=p.read_csv('C:\\Users\\DELL\\Untitled Folder\\Iris.csv')
print("meandis",d.mean())
print("mode is",d.median())

You might also like