0% found this document useful (0 votes)
16 views

3rd EXPERIMENT

This document is an experiment report submitted by a student. It explores the NumPy and Pandas libraries in Python for data analysis. The student performed various operations with arrays and datasets, including creating arrays, appending values, generating random integers, reading CSV files, and calculating correlations. The student demonstrated the use of NumPy for array operations and Pandas for working with datasets. The report concludes the student learned how to use key aspects of NumPy and Pandas through this experiment.
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)
16 views

3rd EXPERIMENT

This document is an experiment report submitted by a student. It explores the NumPy and Pandas libraries in Python for data analysis. The student performed various operations with arrays and datasets, including creating arrays, appending values, generating random integers, reading CSV files, and calculating correlations. The student demonstrated the use of NumPy for array operations and Pandas for working with datasets. The report concludes the student learned how to use key aspects of NumPy and Pandas through this experiment.
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/ 13

University Institute of Engineering

Department of Computer Science & Engineering

Experiment
Student Name: Dev Pundir UID:23BCS10576
Branch:Computer Science & Engineering Section/Group:202-A
Date of Performance:Sept26,2023 Semester: 1st
Subject Name: Disruptive Technology-1 Subject Code: 23ECH-102

1.Aim of the practical:


Exploring Pandas and NumPy library for Data analysis in Python.

2. Tool Used:

Google colaboratory

3.Theory:
Data Analytics: The process of examining datasets to draw conclusions about the
information they contain. Data analytic techniques enable you to take raw data and
uncover patterns to extract valuable insights from it. Many data analytics techniques use
specialized systems and software that integrate machine learning algorithms, automation
and other capabilities.

NumPy: NumPy stands for ‘Numerical Python’ or ‘Numeric Python’. It is an open


source module of Python which provides fast mathematical computation on arrays and
matrices. Since, arrays and matrices are an essential part of the Machine Learning
ecosystem, NumPy along with Machine Learning modules like Scikit-learn, Pandas,
Matplotlib, TensorFlow, etc. complete the Python Machine Learning Ecosystem.

Pandas: Pandas is one of the most widely used python libraries in data science. It
provides high-performance, easy to use structures and data analysis tools. Unlike NumPy
library which provides objects for multi-dimensional arrays, Pandas provides in-memory
2d table object called Dataframe. It is like a spreadsheet with column names and row
labels.
23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

4. Code and output:


1. ARRAY

import numpy as n

c=[12,331,30,40,50,60,70,80,90,12331]

d=n.array(c)

print(c)

print(d)

print(type(c))

print(type(d))

OUTPUT

2. APPENDING

import numpy as n

c=[10,20,30,40,50,60,70,80,90,100]

c.append(12331)

print(c)

c[4]=10544

print(c)

OUTPUT

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

3. ARRAY HAVING ZEROS AND ONES

#array having all ones

import numpy as n

c=n.ones((4,5,3))

d=n.zeros((5,4,3))

#dimension rows then columns

print(c)

print(d)

OUTPUT

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

4. ARRANGING AND RESHAPING

import numpy as n

c=n.arange(10)

print(c,type(c))

d=n.arange(10).reshape(10,1)

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

print(d, type(d))

e=n.arange(10).reshape(5,2)

print(e, type(e))

OUTPUT

5. LINESPACING

import numpy as n

c=n.linspace(4,30,30)

print(c)

d=n.linspace(4,8,5)

print(d)

OUTPUT

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

6.RANDOM INTEGER

import numpy as n

a=n.random.randint(10,91, (4,3))

print(a,"\n", a.shape,a.dtype)

print("*"*30)

b=n.random.random_sample(size=(5,3))

print(b,"\n", b.shape,b.dtype)

print("*"*30)

c=n.random.randint(10,15,size=(3,2))

print(c,"\n", c.shape,c.dtype)

print("*"*30)

OUTPUT

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

7.DATE RANGE IN PANDAS

# Creating a DataFrame by passing a NumPy array, with a datetime index using

#date_range() and labeled columns:

import pandas as pd

dates = pd.date_range("20230601", periods=6)

dates

OUTPUT

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

8.Reading CVS Files

import pandas as pd

df = pd.read_csv('/content/data14.csv')

print(type(df))

df.head()

df.tail()

OUTPUT-

9.INDEXING ,SUMMARY AND INFO


23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

import pandas as pd

df = pd.read_csv('/content/data14.csv')

df.index

df.describe()

df.info()

OUTPUT--

10.Correlation and isnull

import pandas as pd
23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

df = pd.read_csv('/content/data14.csv')

df.corr()

df.isnull()
OUTPUT—

11.Loc and iloc

import pandas as pd

df = pd.read_csv('/content/data14.csv')
23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

# Syntax --> iloc[ ROW, COL_Position]

df.iloc[20:30, 1:5]

# Syntax --> loc[ ROW, COL_Names_in_List ]

df.loc[:10 , ['F1','F3','F6']]

OUTPUT—

12.Transpose

import pandas as pd

df = pd.read_csv('/content/data14.csv')

c=df.T

print(c)

OUTPUT--

13.Dimension of dataset

import pandas as pd

df = pd.read_csv('/content/data14.csv')

23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

df.head()

print("df.shape -->", df.shape)

print("Rows -->", df.shape[0]) ##axis 0---row

print("Columns -->", df.shape[1]) ###column

OUTPUT—

4. Result and Summary:


We Learnt how to use numpy and pandas library in python. We also performed
various operations with arrays using numpy and pandas.

5. Learning outcomes:
1.Array-We learnt how to form array using numpy .We also learnt the difference
between list and arrays.

2.Append-We learnt how to add a number at the end of a list or array.

3.Zeros and ones- We learnt to create arrays using only zeros and ones.

4.Arrange-We learnt to arrange and reshape using numpy .

5.Line spacing- We learnt that linespacing Return evenly spaced numbers over a
specified interval.
23BCS10576
University Institute of Engineering
Department of Computer Science & Engineering

6.Random integers-We learnt to take random integers between different intervals.

7.Data range- We learnt to use data range using pandas.

8.Reading cvs file- We learnt that tail command read last 5 rows of dataset and head
command does the same for first 5 dataset rows .

9.Indexing summary and info- We learnt that index prints the total indexing,
summary prints the mathematical summary and info prints the details about that
array using pandas.

10.Correlation and isnull- We learnt that correlation finds the correlation ad isnull
prints a bool that the input is null or not using pandas.

Evaluation Grid:
Sr. Parameters Marks Obtained Maximum Marks
No.
1. Student Performance 12
(Conduct of experiment)
2. Viva Voce 10
3. Submission of Work Sheet 8
(Record)
Signature of Faculty (with Date): Total Marks Obtained: 30

23BCS10576

You might also like