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

Unit 2 Notes

The document provides an overview of data acquisition, types of data sources, and data formats, emphasizing the importance of structured and unstructured data. It also covers practical examples of importing data using Python, including CSV and Excel files, and introduces basic data cleaning techniques to handle dirty data. The document concludes with a lab exercise focused on employee salary calculations using Python functions and data manipulation with Pandas.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views25 pages

Unit 2 Notes

The document provides an overview of data acquisition, types of data sources, and data formats, emphasizing the importance of structured and unstructured data. It also covers practical examples of importing data using Python, including CSV and Excel files, and introduces basic data cleaning techniques to handle dirty data. The document concludes with a lab exercise focused on employee salary calculations using Python functions and data manipulation with Pandas.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. What is Data Acquisition?

Data Acquisition = Collecting data from different places.


Just like a teacher collects attendance from students every day, companies collect
data to make decisions.
Why do we collect data?
 To know how much a company earned
 To find which product is selling the most
 To understand customer needs
 To check employee performance
Simple Example:
A shopkeeper notes daily sales in a notebook. That notebook is data, and writing
in it every day is data acquisition.

2. Types of Data Sources


Data comes from two types of sources:

A. Internal Data Sources


Internal = Inside the company
Examples:
 Sales Data → How many items sold today
 HR Data → Employee attendance, salary, leaves
 Finance Data → Income, expenses, profit
Simple Example:
Your school’s internal data: attendance register, marksheet, fee records.

B. External Data Sources


External = Outside the company
Examples:
 Government Data → Population, road data, rainfall report
 Surveys → Asking people questions
 API Data → Online apps giving data (example: weather app shows
temperature from a server)
Simple Example:
Your school uses weather data from the internet to decide if the sports event will
be postponed.

3. Structured vs Unstructured Data


Structured Data (Neatly Organized)
 Stored in rows and columns (like in Excel)
 Easy to search
 Example:
o Marksheet
o Salary sheet
o Product list
Simple Example:
Your marks table: Name | Maths | English | Science
This is structured because it's well organized.

Unstructured Data (Not Organized)


 Not in row/column format
 Hard to search
 Examples:
o Images
o Videos
o WhatsApp messages
o PDF documents
Simple Example:
Your phone gallery — lots of photos, no rows/columns — this is unstructured.

4. Real-world Examples of Data


A. Employee Data
 Name
 Age
 Salary
 Attendance
Used by HR department.
B. Sales Data
 Product name
 Quantity
 Price
 Date of sale
Used by sales team to know profit.
C. Customer Data
 Name
 Phone number
 What they purchased
Used for marketing and offers.

Use simple everyday examples:


 Salary sheet → Structured data
 Sales report of a kirana shop → Internal data
 Rainfall data from a mobile app → External data
 YouTube videos → Unstructured data
 Attendance register → Data acquisition

Lecture 2 : Importing Data


1. CSV, Excel & Text Files
A. CSV File (Comma Separated Values)
 It is a simple file where values are separated by commas.
 Works like an Excel table but simpler.
 Extension: .csv
Example:
Name,Marks,Class
Rohan,88,10
Aditi,92,10
B. Excel File
 More powerful than CSV
 Can have formulas, colors, multiple sheets
 Extension: .xlsx
Example: Your school marksheet is usually in Excel.
C. Text File (TXT)
 A normal file with only text.
 No rows/columns like Excel.
 Extension: .txt
Example: Notes written in Notepad.

2. Importing Data Using Python


Students should understand why we import data:
👉 To analyze data, Python first needs to load the file into memory.
Just like opening a notebook before reading it.

A. Python csv Module


 Used to read CSV files.
 CSV files have comma-separated values, so the csv module reads them
line by line.
Simple example:
import csv

with open("[Link]") as file:


data = [Link](file)
for row in data:
print(row)
Explanation :
 open() = open the file
 [Link]() = read the file
 for row in data: = show each line

B. Pandas Library
Pandas is a very famous Python library used for data analysis.
You can think of Pandas like Excel inside Python.

1. read_csv()
Used to read CSV files.
import pandas as pd
data = pd.read_csv("[Link]")
print(data)
Simple meaning:
Pandas opens the CSV file like an Excel sheet.

2. read_excel()
Used to read Excel files.
data = pd.read_excel("[Link]")
print(data)
Simple meaning:
This reads an Excel sheet directly into Python.

3. API (Introduction Only)


API = A way to get data from the internet automatically.
Full form: Application Programming Interface
Don't go deep — just simple concept.
Example
Your weather app shows today’s temperature.
Where does it get the data from?
👉 From a weather API.
How does it work?
 Python sends a request: “Give me today’s weather.”
 API sends back the data: “Temperature = 29°C.”
Tiny Example (Just for understanding):
import requests

response = [Link]("[Link]
print([Link]())
Explain :
 [Link]() → asking data from internet
 .json() → reading the data returned
Don't worry if they don’t understand fully — just give them the idea.

Practical Examples
Example 1: Read a CSV File
Name,Age,Class
Riya,15,10
Arjun,16,10
Using Pandas:
import pandas as pd
data = pd.read_csv("[Link]")
print(data)

Example 2: Read Attendance Excel File


data = pd.read_excel("[Link]")
print([Link]())
.head() = show first 5 rows.

Example 3: Simple API Example (Concept Only)


 Weather app
 Cricket score apps
 Online maps
These all use APIs.

Topic: Importing Data (CSV → Python)


STEP 1: Start with a Simple School
Example
“Suppose we have a marksheet of 3 students.”
Write this on the board:
Name Maths Science
Rohan 85 90
Aditi 92 88
Sameer 78 80

STEP 2: Show the Same Table in


Excel
Open Excel and type the same data:
Name | Maths | Science
Rohan | 85 | 90
Aditi | 92 | 88
Sameer | 78 | 80

STEP 3: Save the File as CSV


In Excel:
1. Click File
2. Click Save As
3. Select CSV (Comma delimited) (*.csv)
4. Save as → [Link]

“Now our marksheet is saved in CSV format — a common data format.”

STEP 4: Open the CSV File in


Notepad
Right-click → Open with → Notepad
Students will see:
Name,Maths,Science
Rohan,85,90
Aditi,92,88
Sameer,78,80
Explain:
“CSV stores table data using commas.”

STEP 5: Read This CSV File Using


Python
Open any Python environment (IDLE, Jupyter, VS Code, etc.)
Use this simplest code:
✅ Using Pandas (Beginner Friendly)
import pandas as pd

df = pd.read_csv("[Link]")
print(df)

STEP 6: Show the Output to Students


The output will look like a table:
Name Maths Science
0 Rohan 85 90
1 Aditi 92 88
2 Sameer 78 80
Explain:
 Python loaded the CSV file
 Pandas converted the data into a table
 We can now analyze marks using Python

STEP 7: Keep Coding Explanation


Light
Tell them:
 import pandas as pd → bringing pandas library
 pd.read_csv() → reads csv file
 df → data stored in table format
Avoid deep coding. Focus on concept.

STEP 8: Give a Simple Practical Task


(Optional)
Ask students to create a CSV file for:
 Attendance
 Fees list
 Library books
And read it using Python.
🎉 Example (Complete Flow)
Marksheet (Excel → CSV → Notepad → Python Print)
This covers:

✔ Excel to CSV conversion


✔ Demonstrating CSV in Notepad
✔ Reading CSV using Python
✔ Showing data output
✔ Concept-based teaching
Lab:1. Define functions to compute KPIs (e.g., profit margin, bonus, net
salary).

LAB–1 : Employee Salary


Calculations using Python
What students will learn
✔ How to define simple Python functions
✔ How to read employee data from a CSV file
✔ How to calculate Gross Salary, Bonus, Net Salary
✔ How to write updated data to a new CSV file

----------------------------------
STEP–1: Create Employee CSV File
----------------------------------
to create a file named [Link]
Open Excel → Save As → CSV
Data:
Name,Basic,Allowances
Ravi,20000,5000
Meena,25000,8000
Ajay,18000,6000
Explain:
 Basic = basic salary
 Allowances = extra amount (travel, food etc.)

----------------------------------
STEP–2: Define Python Functions for
KPIs
----------------------------------
Explain: Functions help us reuse formulas.
def gross_salary(basic, allowances):
return basic + allowances

def bonus(gross):
return gross * 0.10 # 10% bonus

def net_salary(gross, bonus_amount):


return gross + bonus_amount
Explain in simple words:
 Gross Salary = Basic + Allowances
 Bonus = 10% of Gross
 Net Salary = Gross + Bonus

----------------------------------
STEP–3: Read Employee Data from
CSV
----------------------------------
Use pandas to read data:
import pandas as pd

df = pd.read_csv("[Link]")
print(df)
Let students see the table printed.

----------------------------------
STEP–4: Calculate Gross, Bonus &
Net Salary
----------------------------------
Apply your functions to the data:
df["Gross"] = [Link](lambda row: gross_salary(row["Basic"],
row["Allowances"]), axis=1)
df["Bonus"] = df["Gross"].apply(bonus)
df["NetSalary"] = [Link](lambda row: net_salary(row["Gross"],
row["Bonus"]), axis=1)

print(df)
Now students will see a new table:
Name Basic Allowances Gross Bonus NetSalary
----------------------------------
STEP–5: Write Updated Data to New
CSV File
----------------------------------
Save the updated table:
df.to_csv("updated_employee_salary.csv", index=False)
Explain:
 Python creates a new CSV file
 This file contains all salary calculations

----------------------------------
LAB MAPPING (How tasks match
your requirements)
----------------------------------
🔹 Lab Task 1 → Define Python Functions for KPIs
 Functions: gross_salary, bonus, net_salary
🔹 Lab Task 2 → Read Employee Data from CSV
 Using: pd.read_csv("[Link]")
🔹 Lab Task 3 → Calculate Salaries & Save New CSV
 Compute → Gross, Bonus, NetSalary
 Save → to_csv("updated_employee_salary.csv")

Lecture–3: Data Cleaning


Topic: Data Cleaning & Transformation

1. What is Dirty Data?


Dirty Data = Wrong, missing, or repeated data in a dataset.
Just like your notebook may have:
 Spelling mistakes
 Blank pages
 Same thing written twice
 Wrong marks
Similarly, datasets also have problems.
Examples of Dirty Data:
1. Missing values
o Name = Rohan
o Maths Marks = blank
2. Duplicate records
o Same student entry appears twice
3. Wrong values / outliers
o A student’s age is 150 (impossible)
Dirty data gives wrong results, so it must be cleaned.

2. Missing Values
When some data is empty or blank, it is called a missing value.
Example dataset:
Name Maths
Rohan 85
Aditi
Ajay 90
Aditi’s marks are missing.

2A. Detecting missing values → .isnull()


Python code:
[Link]()
This shows True where values are missing.
Example output:
Name Maths
Rohan False
Aditi True
Ajay False

2B. Fixing missing values → .fillna()


We can fill missing values with:
 Average marks
 Zero
 A fixed number (like 0)
Example:
df["Maths"] = df["Maths"].fillna(0)
Now data becomes:
Name Maths
Rohan 85
Aditi 0
Ajay 90

2C. Removing rows with missing values → .dropna()


df = [Link]()
This removes Aditi’s row completely.
Use dropna only when missing data is useless.
3. Duplicate Records
Duplicate = same row repeated twice.
Example dataset:
Name Marks
Rohan 85
Rohan 85
Aditi 92
Rohan appears twice → this is a duplicate record.

3A. Detect duplicates → .duplicated()


[Link]()
Output:
Name Marks duplicated
Rohan 85 False
Rohan 85 True
Aditi 92 False

3B. Remove duplicates → .drop_duplicates()


df = df.drop_duplicates()
Final clean dataset:
Name Marks
Rohan 85
Aditi 92

4. Outliers (Basic Idea Only)


Outliers = very big or very small values that do not make sense.
Example:
Student Age
Rohan 15
Aditi 16
Ajay 150
150 is impossible → this is an outlier.
Why do outliers happen?
 Typing mistake
 Wrong data entry
 Sensor error
What do we do?
 Identify them
 Remove or correct them
⭐ Class Activity: Before & After
Cleaning
Use this dataset:
Name Maths Science
Rohan 85 90
Aditi 88
Ajay 78
Rohan 85 90
Sameer 500 80
Problems:
 Aditi → missing value
 Ajay → missing value
 Duplicate row → Rohan
 Sameer → outlier (Maths = 500)

After Cleaning
Name Maths Science
Rohan 85 90
Aditi 0 88
Ajay 78 0
Sameer 80? 80
Actions done:
 Missing values filled with 0
 Duplicate row removed
 Outlier 500 → corrected or removed

🌟 Summary
✔ Dirty Data = mistakes in data
✔ Missing values → blank spaces
✔ Use .isnull(), .fillna(), .dropna()
✔ Duplicate data → remove using .drop_duplicates()
✔ Outliers → extremely wrong numbers
Lab2. Read employee data from a CSV and write updated data to a new file
after applying calculations.

🎯 Goal
1. Read employee data from a CSV file
2. Do some calculations (Gross, Bonus, Net Salary)
3. Save the updated data into a new CSV file
We will do this in 5 simple steps

✅ STEP 1: Create the Employee CSV


File
Open Excel → Enter this data:
Name Basic Allowances
Ravi 20000 5000
Meena 25000 8000
Ajay 18000 6000
Now save it as:
👉 [Link]
How to save CSV?
File → Save As → Choose CSV (Comma delimited) (.csv)

✅ STEP 2: Create Python Functions


for Calculations
Open your Python editor (IDLE / Jupyter Notebook).
Type this:
def gross_salary(basic, allowances):
return basic + allowances

def bonus(gross):
return gross * 0.10 # 10% bonus

def net_salary(gross, bonus_amt):


return gross + bonus_amt
💡 These functions help us calculate salary easily.

✅ STEP 3: Read the CSV File Using


Pandas
Now type this code:
import pandas as pd

df = pd.read_csv("[Link]")
print("Original Data:")
print(df)
✔ This will read [Link]
✔ It will print the table on the screen
You should see:
Name Basic Allowances
0 Ravi 20000 5000
1 Meena 25000 8000
2 Ajay 18000 6000

✅ STEP 4: Apply Salary Calculations


to Each Employee
Now apply your functions:
df["Gross"] = [Link](lambda row: gross_salary(row["Basic"],
row["Allowances"]), axis=1)
df["Bonus"] = df["Gross"].apply(bonus)
df["NetSalary"] = [Link](lambda row: net_salary(row["Gross"],
row["Bonus"]), axis=1)

print("Updated Data:")
print(df)
✔ This will add 3 new columns
(Gross, Bonus, NetSalary)
Example output:
Name Basic Allowances Gross Bonus NetSalary
0 Ravi 20000 5000 25000 2500 27500
1 Meena 25000 8000 33000 3300 36300
2 Ajay 18000 6000 24000 2400 26400

✅ STEP 5: Write Updated Data to a


NEW CSV File
Use:
df.to_csv("updated_employee_salary.csv", index=False)
✔ This creates a new file with updated salary calculations
✔ No index numbers will be saved (index=False)
You will now find a new file:
👉 updated_employee_salary.csv

🌟 Final Lab Flow Summary


1️⃣ Create [Link]
2️⃣ Write Python salary functions
3️⃣ Read CSV using pd.read_csv()
4️⃣ Calculate Gross, Bonus, Net Salary
5️⃣ Save final output to new CSV
This completes the Lab exactly as required.

Lecture–4 : Data Type Conversion


1. What Are Data Types?
In a dataset, every value has a data type — just like items have categories in a
shop.
Examples:
 15 → number (integer)
 78.5 → decimal number (float)
 “Aditi” → text (string)
 “2024-02-01” → date
⭐ Why Do Data Types Matter?
Because computers treat every type differently.
Example 1: Text vs Number
 If marks are stored as text:
"85" + "10" → "8510" (joining text)
 If marks are stored as numbers:
85 + 10 → 95 (correct calculation)
Example 2: Date stored as text
If a date is stored as “01-02-2024” as text,
you cannot find:
 which date is earlier
 number of days difference
 month or year
So for correct analysis, data type must be correct.

2. Common Data Types in Business


Analytics
✔ int → integer (whole number)
Examples: 10, 45, 20000
✔ float → decimal number
Examples: 99.5, 75.2
✔ string → text
Examples: “Delhi”, “Rohan”, “Class 10”
✔ date → real date format
Examples: 2024-01-05, 2024-02-10

3. Type Conversion in Pandas


Sometimes, when we read a CSV file, everything becomes string (text).
We must convert to correct types to do calculations.

A. Convert Data Type Using .astype()


.astype() is used to convert a column into int, float, or string.
Example Dataset (CSV)
Name Maths Science
Rohan "85" "90"
Aditi "92" "88"
Maths and Science are text — we convert to number:
df["Maths"] = df["Maths"].astype(int)
df["Science"] = df["Science"].astype(int)
Now Python can add and calculate marks.
B. Convert Text to Date Using pd.to_datetime()
Sometimes dates are stored as text:
Date
"2024-01-01"
"2024-01-05"
Convert:
df["Date"] = pd.to_datetime(df["Date"])
Now Python understands:
 year
 month
 day
 can sort dates
 can calculate difference

4. Basics of Feature Transformation


Feature Transformation = changing a column to make data better for analysis.
✔ 1. Create a new column
Example: Convert marks to grade
df["Grade"] = df["Marks"].apply(lambda x: "A" if x >= 90 else "B")
✔ 2. Combine columns
First name + Last name → Full name
df["FullName"] = df["FirstName"] + " " + df["LastName"]
✔ 3. Change units
Monthly salary → yearly salary
df["YearlySalary"] = df["MonthlySalary"] * 12
✔ 4. Extract year, month from date
df["Year"] = df["Date"].[Link]
df["Month"] = df["Date"].[Link]

⭐ Summary
✔ Data type = kind of data (number, text, decimal, date)
✔ Correct data type = correct calculations
✔ Use .astype() to convert to int, float, string
✔ Use pd.to_datetime() to convert to date
✔ Feature transformation = making new useful columns

Descriptive Statistics & EDA


Lecture–5
Subject: Introduction to Business Analytics

🔹 What is Descriptive Statistics?


Descriptive Statistics means:
Using numbers to summarize and understand data easily.
Instead of seeing a long list of numbers, we use:
 Average
 Middle value
 Most common value
 Spread of data
📌 Example:
Marks of students, salaries of employees, sales of a shop, etc.

1️⃣ Mean, Median, Mode


These three tell us central value of data.

✅ Mean (Average)
Formula:
Mean=Sum of all values/ Number of values
📘 Example (Marks)
Marks: 50, 60, 70, 80, 90
Mean = (50 + 60 + 70 + 80 + 90) ÷ 5
Mean = 70
📌 Meaning:
On average, students scored 70 marks.

✅ Median (Middle Value)


Steps:
1. Arrange data in ascending order
2. Find the middle value
📘 Example
Marks: 40, 50, 60, 70, 80
Median = 60
📌 If number of values is even → take average of two middle values.

✅ Mode (Most Repeated Value)


Mode = value that appears maximum times
📘 Example
Marks: 50, `, 70, 80
Mode = 60
📌 Useful when we want to know most common value

🔍 When to Use What?


Measure Used When
Mean Data is balanced
Median Data has very high/low values
Measure Used When
Mode Most common value needed

2️⃣ Variance & Standard Deviation (Very Easy


Explanation)
These tell us:
How spread out the data is

✅ Variance
Variance shows:
 How far values are from the mean
📌 High variance → values are very different
📌 Low variance → values are close together

✅ Standard Deviation (SD)


 Square root of variance
 More commonly used than variance
 Easy to understand spread
📌 Small SD → Data is stable
📌 Large SD → Data is irregular

📘 Simple Example
Marks of Class A:
60, 61, 62, 63, 64 → Low SD
Marks of Class B:
30, 50, 70, 90, 100 → High SD
👉 Class A performance is more consistent

3️⃣ Business Interpretation


(Very Important for Business Analytics)

🛒 A. Sales Performance
Example:
Daily sales (₹):
1000, 1200, 1100, 1150, 1050
 Mean sales → Average daily sale
 Median → Typical sales day
 Low SD → Stable business
 High SD → Sales fluctuate a lot
📌 Business Decision:
 Stable sales → good planning
 Unstable sales → improve marketing
💼 B. Salary Distribution
Example:
Salaries (₹):
10,000, 12,000, 15,000, 20,000, 1,00,000
 Mean salary → Looks high
 Median salary → More realistic
 High SD → Salary inequality
📌 Important Point:
👉 In salary data, Median is better than Mean

4️⃣ Using Python

🧮 A. Using NumPy
Example: Finding Mean, Variance, SD
import numpy as np

marks = [50, 60, 70, 80, 90]

print("Mean:", [Link](marks))
print("Variance:", [Link](marks))
print("Standard Deviation:", [Link](marks))
📌 Output:
Mean: 70
Variance: 200
Standard Deviation: 14.14

🐼 B. Using Pandas .describe()


.describe() gives all statistics in one step
Example:
import pandas as pd

data = {
"Salary": [10000, 12000, 15000, 20000, 100000]
}

df = [Link](data)
print([Link]())
📌 Output includes:
 count
 mean
 std
 min
 25%, 50% (median), 75%
 max

📊 Why .describe() is Useful?


✔ Saves time
✔ Used in EDA (Exploratory Data Analysis)
✔ Helps understand data quickly before decision-making

✨ What is EDA?
EDA = Exploring data before using it
👉 We use:
 Mean
 Median
 Standard Deviation
 Charts (later)

Lecture–6: Introduction to EDA


Subject: Introduction to Business Analytics

1️⃣ What is EDA? (Exploratory Data Analysis)


EDA means:
Looking at data carefully to understand it before making decisions
📌 In simple words:
 We explore data
 We check what the data contains
 We find patterns, mistakes, and useful information

📘 Example:
A shop owner has sales data of 1 year.
Before deciding:
 Which product sells most?
 Which month has highest sales?
👉 First step is EDA

2️⃣ Why is EDA Important?


EDA is important because it helps us to:
✔ Understand the data
✔ Find errors or missing values
✔ Know how big the data is
✔ Make correct business decisions
✔ Avoid wrong conclusions

🧠 Real-Life Example:
If salary data has one person earning ₹1,00,000 and others ₹10,000,
Mean salary looks high ❌
EDA helps us see the real picture ✅
3️⃣ Basic Exploration Methods (Using Pandas)
We use Pandas library in Python to explore data easily.

🔹 .head()
Shows first 5 rows of data.
Example:
[Link]()
📌 Use:
 To see how data looks
 To understand columns

🔹 .tail()
Shows last 5 rows of data.
[Link]()
📌 Use:
 To check last entries
 To see recent records

🔹 .info()
Gives basic information about data.
[Link]()
Shows:
 Number of rows
 Column names
 Data types
 Missing values
📌 Very important for beginners!

🔹 .describe()
Gives summary statistics of numerical data.
[Link]()
Includes:
 count
 mean
 standard deviation
 min, max
 median (50%)
📌 Helps in quick understanding

4️⃣ Row & Column Selection

🔹 Selecting a Column
df["Salary"]
📌 Used when we want to analyze one column.

🔹 Selecting Multiple Columns


df[["Salary", "Age"]]

🔹 Selecting Rows by Position


[Link][0:5]
📌 Selects first 5 rows.

🔹 Selecting Rows by Condition


df[df["Salary"] > 20000]
📌 Shows employees with salary above ₹20,000.

5️⃣ Simple Summary Insights


After EDA, we can answer questions like:
✔ What is the average sales?
✔ Which salary is most common?
✔ Is data balanced or spread out?
✔ Are there missing values?
✔ Is the data reliable?

🛒 Example: Sales Data Insight


 Mean sales = ₹12,000
 Standard deviation = low
👉 Sales are stable

💼 Example: Salary Data Insight


 Mean salary = ₹30,000
 Median salary = ₹15,000
👉 Few high salaries are affecting the average

📌 EDA in Business Analytics


EDA helps businesses to:
 Improve sales strategy
 Decide employee salaries
 Identify loss or profit trends
 Plan future actions

📝 One-Page Summary
 EDA = Exploring data before analysis
 Important for correct decisions
 Pandas functions:
o .head(), .tail() → View data
o .info() → Data details
o .describe() → Statistics
 Row & column selection helps focus on required data
 EDA gives useful insights

Lab–3 : Descriptive Statistics & Basic


EDA
Subject: Introduction to Business Analytics

🎯 Aim of the Lab


To:
 Calculate Mean, Median, Standard Deviation
 Explore data using:
o .head()
o .tail()
o .info()
o .describe()
 Extract specific rows and columns
 Summarize product / employee statistics

🧰 Tools Required
 Python
 Libraries:
o NumPy
o Pandas

📂 Dataset Used (Sample – Employee Data)


We will use a simple employee dataset so that students can relate easily.
EmpID Name Age Salary Department
101 Ravi 25 15000 Sales
102 Neha 28 18000 HR
103 Aman 30 25000 IT
104 Pooja 35 40000 IT
105 Rohit 40 60000 Management

1️⃣ Import Required Libraries


import numpy as np
import pandas as pd

2️⃣ Create the Dataset


data = {
"EmpID": [101, 102, 103, 104, 105],
"Name": ["Ravi", "Neha", "Aman", "Pooja", "Rohit"],
"Age": [25, 28, 30, 35, 40],
"Salary": [15000, 18000, 25000, 40000, 60000],
"Department": ["Sales", "HR", "IT", "IT", "Management"]
}

df = [Link](data)

3️⃣ Calculate Mean, Median & Standard Deviation


🔹 Using NumPy
print("Mean Salary:", [Link](df["Salary"]))
print("Median Salary:", [Link](df["Salary"]))
print("Standard Deviation:", [Link](df["Salary"]))
📌 Explanation:
 Mean → Average salary
 Median → Middle salary
 Standard Deviation → Salary variation

4️⃣ Explore Data (EDA Functions)


🔹 .head() – First 5 Rows
[Link]()
📌 Helps to quickly see how data looks.

🔹 .tail() – Last 5 Rows


[Link]()
📌 Useful for checking recent entries.

🔹 .info() – Data Information


[Link]()
Shows:
 Number of rows
 Column names
 Data types
 Missing values

🔹 .describe() – Statistical Summary


[Link]()
📌 Gives:
 Count
 Mean
 Standard deviation
 Min, max
 Median (50%)

5️⃣ Extract Specific Rows & Columns


🔹 Select One Column
df["Salary"]

🔹 Select Multiple Columns


df[["Name", "Salary"]]

🔹 Select Rows by Position


[Link][0:3]
📌 First 3 employees.

🔹 Select Rows by Condition


df[df["Salary"] > 30000]
📌 Employees earning more than ₹30,000.

6️⃣ Summarize Employee Statistics


🔹 Average Salary
df["Salary"].mean()

🔹 Highest & Lowest Salary


print("Highest Salary:", df["Salary"].max())
print("Lowest Salary:", df["Salary"].min())

🔹 Department-wise Count
df["Department"].value_counts()
📌 Shows number of employees in each department.

7️⃣ Simple Insights (Very Important)


✔ Average salary is influenced by high salaries
✔ IT department has more employees
✔ Salary variation is high → income inequality
✔ Median salary gives a better idea than mean

🧾 Result (For Lab Record)


Thus, descriptive statistics such as mean, median and standard
deviation
were calculated successfully. The dataset was explored using
head(), tail(),
info() and describe() functions. Specific rows and columns were
extracted,
and meaningful employee statistics were summarized using Pandas
and NumPy.

You might also like