Data Analytics Practical File Enhanced
Data Analytics Practical File Enhanced
DATA ANALYTICS
PRACTICAL FILE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Subject: Data Analytics Lab | Session: 2025–26
Session 2025–26
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Academic Year 2025–2026
DATA ANALYTICS PRACTICAL FILE Devendra Sen | CSE | 2025–26
INDEX
This practical file contains 10 experiments covering Data Analytics fundamentals using Python, R, and
MATLAB. Each experiment includes aim, theory, algorithm, program code, sample output, and
conclusion.
📌 Note
All programs were written and tested in Python 3.x environment. R programs were executed in
RStudio. MATLAB experiments were performed using MathWorks MATLAB R2024.
EXP EXPERIMENT
01 Study Basics of Data Analytics
🎯 AIM
To study and understand the fundamental concepts of Data Analytics — its definition, types,
applications, tools, and importance in modern industry.
📖 THEORY
Data Analytics is the systematic process of collecting, organizing, cleaning, analyzing, and interpreting
raw data to uncover meaningful patterns, draw conclusions, and support informed decision-making. It
bridges raw data and actionable intelligence, powering decisions across industries.
💡 Key Insight
Every digital action — a click, a purchase, a sensor reading — generates data. Data Analytics is the
discipline that transforms this raw deluge into competitive advantage.
Diagnostic Analytics Why did it happen? Root cause analysis of a sales decline
✔ Healthcare — Patient outcome prediction ✔ Banking — Fraud detection & credit scoring
✅ CONCLUSION
📝 Conclusion
Data Analytics is the backbone of modern decision intelligence. By understanding its types and tools,
organizations can extract maximum value from data — reducing costs, discovering opportunities,
and gaining competitive edge. This experiment established a strong foundational understanding
essential for all subsequent practical work.
EXP EXPERIMENT
02 Case Study on R Data Analytics Tool
🎯 AIM
To conduct a detailed case study on R — an open-source statistical computing and data visualization
language widely used by data scientists and researchers worldwide.
📖 THEORY
R was developed in 1993 by Ross Ihaka and Robert Gentleman at the University of Auckland. It is a
dialect of the S language and has grown into one of the most popular tools for statistical analysis and
graphical representation. R is the language of choice in academia, research, and data science owing to
its rich ecosystem of packages.
⭐ KEY FEATURES OF R
✔ Active global community & support ✔ Integrates with Python, SQL, Hadoop
📦 POPULAR R PACKAGES
⚖️ ADVANTAGES VS DISADVANTAGES
Advantages Disadvantages
Easy data handling and transformation Slower than Python for large-scale loops
Exceptional graphics with ggplot2 Steep learning curve for new programmers
Active community and frequent updates Less support for production deployment
✅ CONCLUSION
📝 Conclusion
R remains a premier tool for statistical analysis and data visualization. Its comprehensive package
ecosystem, excellent plotting capabilities (especially ggplot2), and strong community support make it
indispensable for data scientists, statisticians, and researchers. While Python may be preferred for
production ML pipelines, R excels in exploratory analysis and statistical modeling.
EXP EXPERIMENT
03 Python — Numerical Operations
🎯 AIM
To write a Python program that accepts a list of numbers from the user and performs key numerical
operations: Maximum, Minimum, Sum, Average, Square Root, and Rounding.
📖 THEORY
Python's built-in functions (max, min, sum, round) combined with the math module provide a
complete toolkit for numerical computation. These operations are foundational for data preprocessing
in analytics pipelines — summary statistics describe a dataset's central tendency and spread before
deeper analysis begins.
💡 Concept
Descriptive statistics like MAX, MIN, and AVERAGE are the very first lens through which a data
analyst examines any new dataset. These operations underpin pandas' .describe() method used
extensively in data science.
⚙️ ALGORITHM
1. Import the math module for advanced operations.
2. Accept a space-separated string of numbers from the user.
3. Split and convert the input into a list of floats using map().
4. Use max(), min(), sum() built-ins to compute respective values.
5. Calculate Average as sum / count of numbers.
6. Accept a second number for sqrt and round operations.
7. Display all results with descriptive labels.
8. Program terminates.
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
# Experiment 3: Numerical Operations in Python
# Author: Devendra Sen | CSE | 2025-26
# ─────────────────────────────────────────────────────
import math
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
Enter numbers separated by spaces: 10 20 30 40 50
✅ CONCLUSION
📝 Conclusion
Python's built-in functions and the math module make numerical computation intuitive and efficient.
This experiment demonstrated how descriptive statistics (max, min, mean, sum) and mathematical
functions (sqrt, round, ceil, floor) can be rapidly implemented — skills directly applicable to EDA
(Exploratory Data Analysis) in real-world data analytics projects.
EXP EXPERIMENT
04 Features & Importance of Python in Data Analytics
🎯 AIM
To study the key features and critical importance of Python as a data analytics tool, and to identify the
major Python libraries used for visualization and analytics.
📖 THEORY
Python was created by Guido van Rossum and released in 1991. Originally designed for general-
purpose programming, it has become the dominant language in data science, machine learning, and
analytics due to its clean syntax, powerful libraries, and massive community. According to the 2024
Stack Overflow Developer Survey, Python is the most popular programming language for the sixth
consecutive year.
✔ Dynamic typing for rapid prototyping ✔ Supports OOP, functional & scripting styles
✔ Extensive standard library included ✔ Strong integration with C/C++ and Java
🔬 VISUALIZATION LIBRARIES
Library Purpose
✅ CONCLUSION
📝 Conclusion
Python's dominance in data analytics stems from its perfect balance of simplicity and power. Its rich
ecosystem — from NumPy for array math to Plotly for interactive dashboards — makes it the go-to
language for the entire analytics lifecycle: data ingestion, cleaning, exploration, modeling, and
visualization. Mastering Python is the most impactful skill investment for any aspiring data analyst.
EXP EXPERIMENT
05 Bayes' Theorem Implementation
🎯 AIM
To implement Bayes' Theorem in Python to compute conditional probability from given values of prior,
likelihood, and marginal probabilities.
📖 THEORY
Bayes' Theorem, formulated by Reverend Thomas Bayes (1701–1761), is one of the most powerful
concepts in probability theory and modern machine learning. It describes how to update the
probability of a hypothesis as new evidence becomes available. The theorem is the foundation of
Naive Bayes classifiers, spam filters, medical diagnosis systems, and Bayesian neural networks.
📐 MATHEMATICAL FORMULA
P(A|B) Posterior Probability Probability of A given that B has occurred (what we want)
⚙️ ALGORITHM
9. Input: P(A) — Prior probability of event A.
10. Input: P(B|A) — Likelihood of evidence B given A.
11. Input: P(B) — Total probability of evidence B.
12. Apply Bayes' formula: P(A|B) = (P(B|A) × P(A)) / P(B).
13. Validate that 0 ≤ each probability ≤ 1 and P(B) ≠ 0.
14. Display the computed posterior probability P(A|B).
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
======= Bayes Theorem Calculator =======
Enter P(A) [Prior] : 0.5
Enter P(B|A) [Likelihood] : 0.8
Enter P(B) [Marginal] : 0.6
─────────────────────────────────────────
P(A|B) = Posterior Probability : 0.666667
As percentage : 66.67%
─────────────────────────────────────────
✅ CONCLUSION
📝 Conclusion
Bayes' Theorem was successfully implemented in Python with input validation and a clean modular
function. The theorem is foundational to probabilistic reasoning in machine learning — powering
spam classifiers, medical diagnostic tools, and recommendation systems. Understanding conditional
probability is essential for any data analyst or ML practitioner.
EXP EXPERIMENT
06 Python — Copy File Content
🎯 AIM
To write a Python program that reads the content of a source text file line-by-line and copies it
accurately into a destination file, demonstrating Python file I/O operations.
📖 THEORY
File handling is a core skill in data analytics because real-world data frequently resides in flat files (.txt,
.csv, .log). Python's built-in open() function with context managers (with statement) provides safe,
efficient access to file system resources. Proper file handling ensures data integrity and prevents
resource leaks.
💡 Best Practice
Always use the "with" statement (context manager) when working with files in Python. It
automatically closes the file — even if an exception occurs — preventing data corruption and
resource leaks.
⚙️ ALGORITHM
15. Open the source file in read mode ("r").
16. Open the destination file in write mode ("w") — creates if not exists.
17. Iterate through the source file line by line using a for loop.
18. Write each line into the destination file using write().
19. Close both file handles (handled automatically by context managers).
20. Print a success confirmation message.
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
# Experiment 6: File Copy — Line by Line
# Author: Devendra Sen | CSE | 2025-26
# ─────────────────────────────────────────────────────
import os
line_count = 0
# ── Execute ────────────────────────────────────────────
copy_file("[Link]", "[Link]")
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
✔ File copied successfully!
Source : [Link]
Destination : [Link]
Lines copied: 42
✅ CONCLUSION
📝 Conclusion
The file copy program was implemented successfully using Python's context managers and line-by-
line iteration — ensuring memory efficiency even for very large files. This experiment reinforced
critical file I/O skills used in real analytics work such as reading log files, processing CSV data, and
copying/archiving datasets.
EXP EXPERIMENT
07 Toyota CSV — Fuel Type Bar Chart
🎯 AIM
To write a Python program that reads Toyota vehicle sales data from a CSV file, filters Petrol and CNG
fuel types, and visualizes their distribution using a professional bar chart.
📖 THEORY
Data visualization is the most impactful stage of data analytics — humans process visual information
60,000× faster than text. Bar charts are ideal for comparing discrete categories (like fuel types).
Pandas' value_counts() instantly aggregates categorical frequency, while Matplotlib and Seaborn
transform that data into compelling visuals. In automotive analytics, fuel-type distribution guides
inventory, pricing, and marketing decisions.
⚙️ ALGORITHM
21. Import pandas and [Link] libraries.
22. Read [Link] into a Pandas DataFrame.
23. Use value_counts() on the 'FuelType' column to count each category.
24. Configure the bar chart with title, axis labels, colors, and grid.
25. Display the plot using [Link]().
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
# Experiment 7: Toyota CSV Visualization — Bar Chart
# Author: Devendra Sen | CSE | 2025-26
# ─────────────────────────────────────────────────────
import pandas as pd
import [Link] as plt
import [Link] as mpatches
plt.tight_layout()
[Link]("toyota_fuel_chart.png", dpi=150)
[Link]()
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
Dataset loaded: 205 rows, 9 columns
FuelType
Petrol 155
Diesel 39
CNG 11
Name: count, dtype: int64
✅ CONCLUSION
📝 Conclusion
The Toyota dataset was successfully loaded, aggregated, and visualized using Pandas and Matplotlib.
The enhanced bar chart with value labels, custom colors, and clean styling demonstrates
professional data visualization practices. This experiment reinforces the complete analytics
workflow: data ingestion → aggregation → visualization → insight communication.
EXP EXPERIMENT
08 Installation & Study of MATLAB Environment
🎯 AIM
To install and explore the MATLAB environment, studying its core components, features, and
applications relevant to data analytics and numerical computing.
📖 THEORY
MATLAB (Matrix Laboratory) is a high-performance numerical computing environment developed by
MathWorks in 1984. It was originally designed for matrix operations — hence the name — and has
evolved into a comprehensive platform for data analysis, algorithm development, simulation, and
visualization. MATLAB is extensively used in engineering, signal processing, image processing, control
systems, and data science.
🔧 INSTALLATION STEPS
3 Sign In Log in with your MathWorks account (create free account if needed)
6 Install & Activate Wait for installation; activate using license key or campus license
7 Launch & Verify Open MATLAB; type "ver" in Command Window to verify installation
Command Window Bottom center Execute commands interactively; see instant results
Workspace Top right View all variables currently in memory with their values
Current Folder Left panel Browse and manage files in the working directory
Editor Window Center top Write, edit, and debug MATLAB scripts (.m files)
✔ Matrix & linear algebra operations ✔ Built-in data visualization & plotting
✔ Signal & image processing toolboxes ✔ Control systems & Simulink integration
✔ Import/Export: CSV, Excel, HDF5, JSON ✔ Code generation to C/C++ & FPGA
✅ CONCLUSION
📝 Conclusion
The MATLAB environment was explored in detail, covering installation, interface components, and its
rich feature set. MATLAB remains the gold standard for numerical computation in engineering and
science — its matrix-first design, extensive toolboxes, and Simulink integration make it uniquely
powerful for signal processing, control systems, and simulation-based analytics that complement
Python/R workflows.
EXP EXPERIMENT
09 Import and Export CSV Files Using Python
🎯 AIM
To write a Python program that demonstrates reading (importing) a CSV file into a Pandas DataFrame,
performing basic data exploration, and writing (exporting) the processed data to a new CSV file.
📖 THEORY
CSV (Comma-Separated Values) is the universal format for data exchange in analytics. Every database,
BI tool, and analytics platform supports CSV. Pandas provides pd.read_csv() — the most feature-rich
CSV reader available — with over 50 parameters for handling encoding, separators, date parsing,
missing values, and more. The to_csv() method provides equally comprehensive export control.
💡 Real-World Context
CSV files account for over 60% of data ingestion tasks in data analytics roles. Mastering pd.read_csv()
with its full parameter set is one of the highest-ROI skills for a data analyst or data engineer.
⚙️ ALGORITHM
26. Import pandas library.
27. Use pd.read_csv() to load [Link] into a DataFrame.
28. Explore: print shape, column names, data types, and first 5 rows.
29. Check for null values using isnull().sum().
30. Apply a basic transformation (add a computed column).
31. Export to [Link] using to_csv() with index=False.
32. Confirm success by printing file size and row count.
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
# Experiment 9: Import & Export CSV Files in Python
# Author: Devendra Sen | CSE | 2025-26
# ─────────────────────────────────────────────────────
import pandas as pd
import os
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
======= Dataset Info =======
Shape : 500 rows × 8 columns
Columns : ['ID', 'Name', 'Age', 'Salary', 'Dept', 'City', 'Score', 'Grade']
First 3 rows:
ID Name Age Salary Dept City Score Grade
0 1 Alice 28 52000 Sales Mumbai 88 A
1 2 Bob 34 61000 IT Delhi 74 B
2 3 Charlie 45 78000 Finance Chennai 91 A
Missing Values:
Salary 12
Score 5
dtype: int64
✅ CONCLUSION
📝 Conclusion
CSV import and export operations were successfully performed using Pandas. The experiment
demonstrated the complete data pipeline: loading raw CSV data, exploring its structure and quality,
applying a transformation, and exporting clean data. These skills form the backbone of every data
analytics workflow — data rarely arrives ready to analyze, and Pandas provides unmatched tools for
the ingestion and preparation stages.
EXP EXPERIMENT
10 Social Media Engagement Data Analysis
🎯 AIM
To analyze social media engagement data using Python and Pandas — computing engagement scores,
generating descriptive statistics, identifying top-performing posts, and extracting actionable insights.
📖 THEORY
Social media analytics is a rapidly growing field with direct business impact. Engagement metrics —
likes, comments, and shares — quantify audience interaction with content. High engagement signals
content relevance, drives algorithmic amplification, and correlates with brand growth. Data-driven
content strategies powered by engagement analysis consistently outperform intuition-based decisions
by 200–400% in reach and conversion.
💡 Industry Context
Brands spend over $200 billion annually on social media. Companies that use engagement analytics
to optimize posting time, content type, and audience targeting achieve 3–5× better ROI than those
that do not analyze their data.
📐 ENGAGEMENT FORMULA
Advanced analytics also uses Engagement Rate = (Engagement / Reach) × 100 to compare
performance across posts with different audience sizes.
📊 SAMPLE DATASET
⚙️ ALGORITHM
33. Create a dictionary with Post_ID, Platform, Likes, Comments, Shares, and Reach.
34. Convert to Pandas DataFrame.
35. Compute Engagement = Likes + Comments + Shares.
36. Compute Engagement_Rate = (Engagement / Reach) × 100.
37. Generate descriptive statistics using describe().
38. Identify the top-performing post (highest engagement).
39. Group and compare performance by platform.
40. Display all results with clear formatting.
💻 PROGRAM CODE
# ─────────────────────────────────────────────────────
# Experiment 10: Social Media Engagement Analysis
# Author: Devendra Sen | CSE | 2025-26
# ─────────────────────────────────────────────────────
import pandas as pd
df = [Link](data)
top = [Link][df["Engagement"].idxmax()]
print(f"\n🏆 Top Post: ID {int(top.Post_ID)} on {[Link]}")
print(f" Engagement : {int([Link])}")
print(f" Eng. Rate : {top.Engagement_Rate}%")
🖥️ SAMPLE OUTPUT
⬛ OUTPUT
======= Social Media Engagement Report =======
Post_ID Platform Likes Comments Shares Reach Engagement
Engagement_Rate
101 Instagram 320 85 45 5200 450
8.65
102 Twitter 200 50 40 3800 290
7.63
103 Facebook 150 30 25 2900 205
7.07
104 LinkedIn 410 120 80 7100 610
8.59
105 Instagram 280 65 55 4600 400
8.70
── Descriptive Statistics ──
Likes Comments Shares Engagement
count 5.00 5.00 5.00 5.00
mean 272.00 70.00 49.00 391.00
std 101.77 35.18 21.07 153.36
min 150.00 30.00 25.00 205.00
max 410.00 120.00 80.00 610.00
✅ CONCLUSION
📝 Conclusion
Social media engagement was analyzed comprehensively — from raw data to descriptive statistics,
top-post identification, and platform comparison. The analysis revealed that LinkedIn delivered the
highest absolute engagement while Instagram showed the highest engagement rate. These insights
demonstrate how data analytics drives social media strategy: content type, platform choice, and
posting patterns can all be optimized using the techniques practiced in this experiment.
FINAL CONCLUSION
All 10 experiments in this Data Analytics Practical File were designed, implemented, and successfully
executed using Python, R, and MATLAB. The progression through this practical file reflects the real-
world analytics workflow:
41. Foundation — Understanding data analytics types, tools, and ecosystem (Exps 1–2).
42. Core Programming — Mastering Python for numerical computation and file operations (Exps 3,
6).
43. Mathematics — Applying probability theory (Bayes) foundational to ML (Exp 5).
44. Data Wrangling — Importing, exporting, and transforming CSV datasets (Exp 9).
45. Visualization — Creating professional charts to communicate insights (Exp 7).
46. Applied Analysis — Real-world social media engagement analytics (Exp 10).
47. Tool Ecosystem — Exploring MATLAB for numerical/engineering analytics (Exp 8).
🎯 Key Takeaways
Data Analytics is not a single skill but an ecosystem of competencies — statistical thinking,
programming, visualization, domain knowledge, and communication. These experiments have built
the foundation across all these dimensions, preparing for advanced topics: machine learning, deep
learning, big data processing with Spark, and real-time analytics.
10 3 ✔
Experiments Completed Tools Mastered (Python, R, All Experiments Passed
MATLAB)