0% found this document useful (0 votes)
0 views36 pages

Python Data Analytics Lab Record(1)

The document is a laboratory record for a Foundations of Data Science course, detailing various practical exercises conducted by a student named Madhumithra.D. It covers the installation and exploration of key Python libraries such as NumPy, SciPy, Pandas, Statsmodels, and Jupyter, along with practical applications including data manipulation, statistical analysis, and data visualization techniques. Each practical includes aims, procedures, and results demonstrating the successful execution of tasks related to data science.

Uploaded by

dmadhumithra2006
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)
0 views36 pages

Python Data Analytics Lab Record(1)

The document is a laboratory record for a Foundations of Data Science course, detailing various practical exercises conducted by a student named Madhumithra.D. It covers the installation and exploration of key Python libraries such as NumPy, SciPy, Pandas, Statsmodels, and Jupyter, along with practical applications including data manipulation, statistical analysis, and data visualization techniques. Each practical includes aims, procedures, and results demonstrating the successful execution of tasks related to data science.

Uploaded by

dmadhumithra2006
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

DEPARTMENT OF COMPUTER SCIENCE AND

ENGINEERING

Foundations of Data Science — Laboratory record

Submitted By

Student Name: Madhumithra.D


Roll Number: 713924104067
Class / Section: II CSE-A
Department: Computer Science and Engineering
TABLE OF CONTENTS
Practical 1 — Download, Install and Explore NumPy, SciPy, Jupyter, Statsmodels and
Pandas
Practical 2 — Working with NumPy Arrays
Practical 3 — Working with Pandas DataFrames
Practical 4 — Reading Data & Descriptive Analytics on the Iris Dataset
Practical 5 — Statistical Analysis on the Diabetes Dataset
Practical 6 — Plotting Functions on the UCI Dataset
Practical 7 — Visualizing Geographic Data with Basemap
PRACTICAL 1: Download, Install and Explore NumPy, SciPy,
Jupyter, Statsmodels and Pandas
Aim: To download, install, and explore the basic features of NumPy, SciPy, Jupyter,
Statsmodels, and Pandas — Python packages widely used for scientific computing and data
analysis.

Procedure / Installation Steps


● Ensure Python (version 3.x) is installed on the system.
● Open the Command Prompt / Terminal.
● Install the required packages using pip.
pip install numpy
pip install scipy
pip install pandas
pip install statsmodels
pip install jupyter

Or install all at once:


pip install numpy scipy pandas statsmodels jupyter

Verify installation by checking the version of each package:


import numpy as np
import scipy
import pandas as pd
import statsmodels

print("NumPy version:", np.__version__)


print("SciPy version:", scipy.__version__)
print("Pandas version:", pd.__version__)
print("Statsmodels version:", statsmodels.__version__)

Launch Jupyter Notebook to work interactively:


jupyter notebook

Description of Each Package


1. NumPy (Numerical Python)
● Core library for numerical computing in Python.
● Provides support for large, multi-dimensional arrays and matrices.
● Offers a large collection of high-level mathematical functions (linear algebra, Fourier transforms, random
number generation).
● Faster than native Python lists because it uses fixed-type, contiguous memory arrays.
import numpy as np
arr = [Link]([1, 2, 3, 4, 5])
print("Array:", arr)
print("Mean:", [Link](arr))
print("Standard Deviation:", [Link](arr))
2. SciPy (Scientific Python)
● Built on top of NumPy; used for advanced scientific and technical computing.
● Provides modules for optimization, integration, interpolation, eigenvalue problems, statistics, and signal
processing.
from scipy import stats
data = [2, 4, 4, 4, 5, 5, 7, 9]
print("Skewness:", [Link](data))
print("Kurtosis:", [Link](data))

3. Pandas
● Library for data manipulation and analysis.
● Provides two main data structures: Series (1D) and DataFrame (2D, table-like).
● Used for reading/writing CSV, Excel, SQL data, handling missing values, filtering, grouping, and merging
datasets.
import pandas as pd
data = {'Name': ['A', 'B', 'C'], 'Marks': [85, 90, 95]}
df = [Link](data)
print(df)
print("Average Marks:", df['Marks'].mean())

4. Statsmodels
● Library for statistical modeling and hypothesis testing.
● Provides classes and functions for estimating statistical models (linear regression, time series analysis,
ANOVA) and performing statistical tests.
import [Link] as sm
import numpy as np
X = [Link]([1, 2, 3, 4, 5])
y = [Link]([2, 4, 5, 4, 5])
X = sm.add_constant(X)
model = [Link](y, X).fit()
print([Link]())

5. Jupyter Notebook
● Web-based interactive computing environment.
● Allows writing and running code in cells, combined with text (Markdown), equations, and visualizations in
a single document.
● Widely used for data analysis, prototyping, and documentation because output (tables, plots) is displayed
inline, right below the code that produced it.

Result
The NumPy, SciPy, Pandas, Statsmodels, and Jupyter packages were successfully downloaded,
installed, and their basic features were explored using sample programs.
PRACTICAL 2: Working with NumPy Arrays
Aim: To create, manipulate, and perform various operations on NumPy arrays, including array
creation, array attributes, arithmetic operations, aggregation, mathematical computations,
boolean indexing, fancy indexing, and structured arrays.

Program & Output


Creating arrays

Array attributes

Array operations
Aggregation

Computations
Boolean index

Fancy indexing

Structured array

Result
NumPy arrays were successfully created and manipulated. Array creation, attributes (shape,
ndim, size, dtype), arithmetic operations, aggregation functions, mathematical computations,
boolean indexing, fancy indexing, and structured arrays were explored and verified with sample
outputs.
PRACTICAL 3: Working with Pandas DataFrames
Aim: To explore Pandas DataFrame operations including data viewing, selection, filtering,
sorting, handling missing values and duplicates, statistical calculations, grouping, pivot tables,
column operations, exporting data, and combining multiple DataFrames.

Program & Output


Data collection and understanding

Viewing the data


Selecting data
Filter

Sorting

Missing values
Finding Duplicates

Statistics Calculation
Group by

Pivot Tables
Column add/remove/rename

Exporting the data


Combining multiple tables
Result
A Pandas DataFrame was successfully created and explored. Operations for viewing, selecting,
filtering, sorting, cleaning (missing values and duplicates), computing statistics, grouping,
pivoting, modifying columns, exporting, and combining/merging DataFrames (concat,
inner/outer/left/right joins) were performed and verified.
PRACTICAL 4: Reading Data & Descriptive Analytics on the
Iris Dataset
Aim: To read data into Pandas from various sources (CSV/text files, Excel, and the web), and to
explore descriptive analytics commands (mean, median, mode, standard deviation, etc.) on the
Iris dataset.

Program & Output


Descriptive analysis
Result
The Iris dataset was successfully loaded into a Pandas DataFrame and checked for missing
values and duplicates. Descriptive statistics (mean, median, mode, standard deviation, etc.) were
computed for sepal length, sepal width, petal length, and petal width, giving a clear numerical
summary of the dataset's characteristics.
PRACTICAL 5: Statistical Analysis on the Diabetes Dataset
Aim: To perform univariate analysis (frequency, mean, median, mode, variance, standard
deviation, skewness, kurtosis), bivariate analysis (linear and logistic regression), and multivariate
analysis (correlation analysis) on the Pima Indians Diabetes dataset.

Program & Output


Univariate analysis
Bivariate analysis
Multivariate analysis
Result
Univariate analysis was performed on the Pregnancies and Glucose features, computing mean,
median, mode, variance, standard deviation, skewness, and kurtosis. Bivariate analysis included
a linear regression of BMI on SkinThickness (R² ≈ 0.171) and a logistic regression predicting
diabetes Outcome from Glucose (accuracy ≈ 75.3%). Multivariate analysis computed the
correlation matrix across all numeric features, visualized as a heatmap.
Note: the analysis in the source notebook was carried out on a single Pima Indians Diabetes
dataset ([Link]); a second UCI diabetes dataset was not included for a side-by-side
comparison in the executed code.
PRACTICAL 6: Plotting Functions on the UCI Dataset
Aim: To apply and explore various plotting functions on the diabetes (UCI) dataset, including
line charts, histograms, scatter plots, density plots, contour plots, and three-dimensional plotting.

Program & Output

Line chart
Histogram chart
Scatter chart
Density plot
Contour plots
3d surface + wireframe
Result
A variety of visualization techniques were applied to the diabetes dataset, including a line chart
of average BMI by Pregnancies, a histogram of Age distribution, a scatter plot of Age vs BMI
colored by Pregnancies, a kernel density plot, a contour plot, and a 3D surface/wireframe plot —
demonstrating Matplotlib and Seaborn's range of plotting capabilities.
PRACTICAL 7: Visualizing Geographic Data with Basemap
Aim: To visualize geographic data using Python mapping libraries — plotting city coordinates
on a longitude/latitude scatter plot, and overlaying real-world map tiles using GeoPandas and
Contextily (a modern equivalent of Basemap, which is now deprecated).

Program & Output


7th practical exercise - visualizing geographical data with basemap
Result
Geographic data was successfully visualized in two ways: first, a simple longitude/latitude
scatter plot labeling four South Indian cities (Bangalore, Hyderabad, Chennai, Coimbatore);
second, a GeoDataFrame point for Chennai was projected to Web Mercator (EPSG:3857) and
plotted over a real OpenStreetMap basemap tile using GeoPandas and Contextily.

You might also like