Data Science Process
Data Science Process
It combines:
📊 Statistics
💻 Programming
🤖 Machine Learning
🗄 Databases
📈 Data Visualization
👉 Simple meaning: Raw data ko useful information me convert karna hi Data Science hai.
8️⃣ Deployment
Deploy model in real system
Example: Recommendation system
🎬 Entertainment
[Link] 2/81
5/13/26, 6:42 PM Data Science Process
Movie recommendation
Example: Netflix
🚗 Transportation
Route optimization
Example: Uber
🏥 Healthcare
Disease prediction
Medical image analysis
📱 Social Media
Ad targeting
Example: Instagram
Process:
Problem → Data Collection → Cleaning → EDA → Modeling → Evaluation → Deployment
Applications:
E-commerce, Healthcare, Banking, Social Media, Transportation
Advantages:
Better decisions, prediction, automation
Challenges:
Data quality, privacy, cost, bias
[Link] 4/81
5/13/26, 6:42 PM Data Science Process
[Link] 5/81
5/13/26, 6:42 PM Data Science Process
Examples:
if
else
elif
while
for
break
continue
def
return
class
True
False
None
and
or
not
import
Example:
if x > 5:
print("Hello")
Python Run
Objects
Example:
age = 20
name = "Sarika"
Python Run
✔ Valid:
name
_age
student1
❌ Invalid:
1name
class
my-name
🔹 Naming Rules
1. Must follow identifier rules
2. Use meaningful names
3. Use lowercase with underscore (recommended)
[Link] 7/81
5/13/26, 6:42 PM Data Science Process
Example:
total_marks = 90
Python Run
🔹 Declaration
Python me alag se declaration nahi hota.
Example:
x = 10
Python Run
🔹 Assignment
Value ko variable me store karna assignment kehlata hai.
Example:
x = 5
Python Run
🔹 Initialization
Variable ko first time value dena initialization kehlata hai.
Example:
count = 0
Python Run
🔹 1. Numeric Types
Type Example
int 10
float 10.5
complex 2+3j
Example:
a = 10
b = 5.5
c = 3+4j
Python Run
🔹 2. Sequence Types
Type Example
str "Hello"
list [1,2,3]
tuple (1,2,3)
🔹 3. Set Type
[Link] 9/81
5/13/26, 6:42 PM Data Science Process
{1,2,3}
🔹 4. Mapping Type
Dictionary:
🔹 5. Boolean Type
True
False
🔹 6. None Type
None
🔹 Types of Literals
1️⃣ Numeric Literals
10
3.14
2+3j
[Link] 10/81
5/13/26, 6:42 PM Data Science Process
"Hello"
'Python'
True
False
None
[1,2,3] → List
(1,2,3) → Tuple
{1,2,3} → Set
{"a":1} → Dictionary
⭐ Features of NumPy
1. Powerful N-dimensional array (ndarray)
2. Faster than normal Python lists
3. Supports mathematical functions
4. Supports linear algebra
5. Supports broadcasting
6. Supports random number generation
📦 Import NumPy
[Link] 12/81
5/13/26, 6:42 PM Data Science Process
import numpy as np
Python Run
🔹 Creating Arrays
import numpy as np
a = [Link]([1,2,3,4])
print(a)
Python Run
2D Array
b = [Link]([[1,2],[3,4]])
Python Run
🔹 Important Functions
Function Use
[Link]() Mean
[Link]() Median
Example:
[Link] 13/81
5/13/26, 6:42 PM Data Science Process
[Link]([1,2,3,4])
Python Run
🔹 Advantages of NumPy
✅ Fast computation
✅ Memory efficient
✅ Used in Machine Learning
📦 Import Pandas
import pandas as pd
Python Run
🔹 Creating Series
[Link] 14/81
5/13/26, 6:42 PM Data Science Process
s = [Link]([10,20,30])
print(s)
Python Run
🔹 Creating DataFrame
data = {
"Name": ["A", "B"],
"Age": [20, 22]
}
df = [Link](data)
print(df)
🔹 Important Functions
Function Use
🔹 Applications
✔ Data cleaning
✔ Data transformation
[Link] 15/81
5/13/26, 6:42 PM Data Science Process
✔ Data analysis
✔ CSV/Excel file handling
Example:
df = pd.read_csv("[Link]")
Python Run
🔹 Advantages
✅ Easy data handling
✅ Powerful filtering
✅ Time series support
📦 Import Matplotlib
[Link] 16/81
5/13/26, 6:42 PM Data Science Process
x = [1,2,3,4]
y = [10,20,25,30]
[Link](x,y)
Python
[Link]()
Run
🔹 Types of Graphs
Graph Type Function
Histogram [Link]()
[Link](["A","B","C"], [10,20,15])
[Link]()
Python Run
🔹 Advantages
✅ Easy visualization
✅ Customizable graphs
✅ Useful for Data Analysis
[Link] 17/81
5/13/26, 6:42 PM Data Science Process
Together, these three libraries form the foundation of Data Science in Python.
Pandas is a Python library created by Wes McKinney for data analysis and manipulation.
[Link] 18/81
5/13/26, 6:42 PM Data Science Process
In simple words:
👉 Raw data ko useful format me convert karna hi data manipulation hai.
ChatGPT Get Plus
import pandas as pd
Python Run
data = {
"Name": ["A", "B", "C"],
"Age": [20, 21, 19],
"Marks": [85, 90, 88]
}
df = [Link](data)
print(df)
🔹 1. Viewing Data
[Link] 19/81
5/13/26, 6:42 PM Data Science Process
[Link]()
Python Run
[Link]()
Python Run
[Link]()
Python Run
[Link]()
Python Run
🔹 2. Selecting Data
Select single column
df["Name"]
Python Run
df[["Name", "Marks"]]
Python Run
[Link] 20/81
5/13/26, 6:42 PM Data Science Process
🔹 5. Updating Values
[Link][0, "Marks"] = 95
Python Run
🔹 6. Deleting Data
Delete column
[Link]("Grade", axis=1)
Python Run
Delete row
[Link] 21/81
5/13/26, 6:42 PM Data Science Process
[Link](0)
Python Run
[Link]()
Python Run
[Link]()
Python Run
[Link](0)
Python Run
🔹 8. Sorting Data
df.sort_values("Marks")
Python Run
Descending order:
df.sort_values("Marks", ascending=False)
Python Run
[Link] 22/81
5/13/26, 6:42 PM Data Science Process
🔹 9. Grouping Data
[Link]("Grade")["Marks"].mean()
Python Run
df = pd.read_csv("[Link]")
Python Run
Write to CSV
df.to_csv("[Link]")
Python Run
Filtering df[condition]
Sorting sort_values()
Grouping groupby()
[Link] 23/81
5/13/26, 6:42 PM Data Science Process
Operation Function
Merging merge()
Concatenation concat()
[Link] 24/81
5/13/26, 6:42 PM Data Science Process
import pandas as pd
Python Run
data = {
"Name": ["A", "B", "C"],
"Age": [20, 21, 19],
"Marks": [85, 90, 88]
}
df = [Link](data)
print(df)
🔹 BASIC OPERATIONS
First 5 rows
[Link]()
Python Run
Last 5 rows
[Link]()
Python Run
Data Information
[Link]()
Python Run
Statistical Summary
[Link]()
Python Run
df["Name"]
Python Run
df[["Name", "Marks"]]
Python Run
[Link] 26/81
5/13/26, 6:42 PM Data Science Process
[Link][0]
Python Run
[Link][0]
Python Run
[Link][0, "Marks"] = 95
Python Run
[Link]("Grade", axis=1)
Python Run
axis=1 → column
axis=0 → row
[Link](0)
Python Run
[Link]()
Python Run
[Link](0)
Python Run
🔟 Sort Data
Ascending:
df.sort_values("Marks")
Python Run
Descending:
[Link] 28/81
5/13/26, 6:42 PM Data Science Process
df.sort_values("Marks", ascending=False)
Python Run
[Link]("Grade")["Marks"].mean()
Python Run
[Link](columns={"Marks": "Total_Marks"})
Python Run
df = pd.read_csv("[Link]")
Python Run
df.to_csv("[Link]")
Python Run
Rows = axis 0
Columns = axis 1
loc → label based
iloc → index based
head() & tail() → data preview
Pandas (created by Wes McKinney) provides easy functions to import and export data.
[Link] 30/81
5/13/26, 6:42 PM Data Science Process
Example:
Name,Age,Marks
A,20,85
B,21,90
import pandas as pd
df = pd.read_csv("[Link]")
Python Run
Example:
import pandas as pd
df = pd.read_csv("[Link]")
print(df)
Python Run
🔹 Important Parameters
Parameter Use
[Link] 31/81
5/13/26, 6:42 PM Data Science Process
Parameter Use
Example:
df = pd.read_csv("[Link]", sep=",")
Python Run
df.to_csv("[Link]")
Python Run
Example:
df.to_csv("[Link]", index=False)
Python Run
[Link] 32/81
5/13/26, 6:42 PM Data Science Process
df = pd.read_excel("[Link]")
Python Run
Example:
import pandas as pd
df = pd.read_excel("[Link]")
print(df)
Python Run
df = pd.read_excel("[Link]", sheet_name="Sheet1")
Python Run
📤 Export to Excel
Syntax:
df.to_excel("[Link]")
Python Run
Example:
df.to_excel("[Link]", index=False)
Python Run
[Link] 33/81
5/13/26, 6:42 PM Data Science Process
[Link] 34/81
5/13/26, 6:42 PM Data Science Process
Example:
[Link] 35/81
5/13/26, 6:42 PM Data Science Process
[Link]()
Python Run
[Link]().sum()
Python Run
[Link]()
Python Run
[Link](axis=1)
Python Run
[Link] 36/81
5/13/26, 6:42 PM Data Science Process
axis=0 → rows
axis=1 → columns
[Link](0)
Python Run
df["Marks"].fillna(df["Marks"].mean(), inplace=True)
Python Run
🔹 Forward Fill
[Link](method="ffill")
Python Run
🔹 Backward Fill
[Link](method="bfill")
Python Run
Example:
A 20 85
A 20 85
[Link] 37/81
5/13/26, 6:42 PM Data Science Process
🐼 Using Pandas
🔹 Check Duplicate Rows
[Link]()
Python Run
🔹 Count Duplicates
[Link]().sum()
Python Run
🔹 Remove Duplicates
df.drop_duplicates()
Python Run
Example:
Male
male
M
🔹 Fixing Inconsistency
Convert to Lowercase
[Link] 38/81
5/13/26, 6:42 PM Data Science Process
df["Gender"] = df["Gender"].[Link]()
Python Run
Replace Values
df["Gender"].replace({"m": "male"})
Python Run
df["Age"] = df["Age"].astype(int)
Python Run
🔹 1. Scaling (Normalization)
Values ko 0–1 range me convert karna.
Example (Manual):
Male → 1
Female → 0
[Link] 39/81
5/13/26, 6:42 PM Data Science Process
🔹 3. Binning
Continuous data ko categories me divide karna.
🔹 4. Rename Columns
[Link](columns={"Marks": "Total_Marks"})
Python Run
📊 Summary Table
Problem Solution
Example:
10 0.0
50 0.5
100 1.0
[Link] 41/81
5/13/26, 6:42 PM Data Science Process
📌 Types of Normalization
1️⃣ Min-Max Normalization
2️⃣ Z-Score Normalization (Standardization)
3️⃣ Max Absolute Scaling
import pandas as pd
print(df)
Python Run
[Link] 42/81
5/13/26, 6:42 PM Data Science Process
scaler = MinMaxScaler()
df["Normalized"] = scaler.fit_transform(df[["Marks"]])
print(df)
✅ Using sklearn
scaler = StandardScaler()
df["Standardized"] = scaler.fit_transform(df[["Marks"]])
Python Run
[Link] 43/81
5/13/26, 6:42 PM Data Science Process
scaler = MaxAbsScaler()
df["MaxAbs"] = scaler.fit_transform(df[["Marks"]])
Python Run
📊 Comparison
Method Range Use Case
[Link] 44/81
5/13/26, 6:42 PM Data Science Process
📌 What is Scaling?
Scaling means adjusting numerical feature values to a similar range.
👉 Example:
Age 25 0.25
If scaling nahi karte, to large values model ko dominate kar sakte hain.
[Link] 45/81
5/13/26, 6:42 PM Data Science Process
👉 Range: 0 to 1
✅ Important Function
scaler = MinMaxScaler()
scaled_data = scaler.fit_transform(data)
Python Run
🔑 Key Methods:
fit()
transform()
fit_transform()
[Link] 46/81
5/13/26, 6:42 PM Data Science Process
👉 Mean = 0
👉 Std = 1
✅ Important Function
scaler = StandardScaler()
scaled_data = scaler.fit_transform(data)
Python Run
scaler = MaxAbsScaler()
scaled_data = scaler.fit_transform(data)
Python Run
[Link] 47/81
5/13/26, 6:42 PM Data Science Process
scaler = RobustScaler()
Python Run
scaled_data = scaler.fit_transform(data)
📊 Comparison Table
Method Range Best For
[Link] 48/81
5/13/26, 6:42 PM Data Science Process
1️⃣ Matplotlib
2️⃣ Seaborn
3️⃣ Plotly
4️⃣ Pandas (built-in plotting)
1️⃣ Matplotlib
Created by John D. Hunter.
[Link] 50/81
5/13/26, 6:42 PM Data Science Process
Import:
x = [1,2,3,4]
y = [10,20,25,30]
[Link](x,y)
[Link]("X Axis")
[Link]("Y Axis")
[Link]("Line Chart")
[Link]()
2️⃣ Seaborn
Built on top of Matplotlib.
Better design & statistical graphs.
Import:
Example:
[Link](x=["A","B","C"], y=[10,20,15])
Python Run
[Link] 51/81
5/13/26, 6:42 PM Data Science Process
3️⃣ Plotly
Interactive graphs (zoom, hover, etc.)
Example:
import [Link] as px
[Link](kind="bar")
Python Run
📊 Comparison of Libraries
Library Best For
[Link] 52/81
5/13/26, 6:42 PM Data Science Process
Descriptive Statistics is used to summarize and describe the main features of a dataset.
👉 It tells:
🎯 Why It Is Important?
1️⃣ Data ko summarize karta hai
2️⃣ Patterns samajhne me help karta hai
3️⃣ Data cleaning me useful
4️⃣ Decision making support
[Link] 54/81
5/13/26, 6:42 PM Data Science Process
📌 Example Dataset
import pandas as pd
import numpy as np
P th R
df["Marks"].mean()
Python Run
👉 Average marks.
2️⃣ Median
df["Marks"].median()
Python Run
👉 Middle value.
3️⃣ Mode
df["Marks"].mode()
Python Run
[Link] 55/81
5/13/26, 6:42 PM Data Science Process
4️⃣ Range
df["Marks"].max() - df["Marks"].min()
Python Run
5️⃣ Variance
df["Marks"].var()
Python Run
df["Marks"].std()
Python Run
👉 Spread of data.
[Link]()
Python Run
👉 Gives:
count
mean
std
min
25%
[Link] 56/81
5/13/26, 6:42 PM Data Science Process
50%
75%
max
8️⃣ Skewness
df["Marks"].skew()
Python Run
9️⃣ Kurtosis
df["Marks"].kurt()
Python Run
👉 Peakedness measure.
📊 Real-Life Applications
Field Application
Descriptive statistics is used to summarize and describe data using numerical measures. It
includes mean, median, mode (central tendency), and variance and standard deviation
(dispersion). In Python, descriptive statistics can be calculated using Pandas functions such
as mean(), median(), std(), var(), and describe(). It helps in understanding data distribution
before further analysis.
Example:
Marks Frequency
0–10 5
10–20 8
20–30 12
30–40 10
👉 Yaha individual values nahi diye gaye, sirf ranges di gayi hain.
ˉ = ∑ fx
X
∑f
Where:
f = frequency
x = class midpoint
Σfx = sum of (frequency × midpoint)
Σf = total frequency
🔹 Step-by-Step Calculation
Example:
Class f Midpoint (x) f×x
0–10 5 5 25
10–20 8 15 120
[Link] 59/81
5/13/26, 6:42 PM Data Science Process
20–30 12 25 300
30–40 10 35 350
Now:
ˉ = A + ∑ fd × h
X
∑f
Where:
A = assumed mean
d = deviation
h = class width
📁 Printable notes
Tell me 👍
📌 What is Median?
Median is the middle value of a dataset when arranged in ascending or descending order.
Example:
10 2
20 3
30 4
[Link] 62/81
5/13/26, 6:42 PM Data Science Process
40 1
Example:
x f CF
10 2 2
20 3 5
30 4 9
40 1 10
Total N = 10
N/2 = 10/2 = 5
👉 Median = 20
[Link] 63/81
5/13/26, 6:42 PM Data Science Process
Example:
Class Frequency
0–10 5
10–20 8
20–30 12
30–40 10
M edian = L + ( )×h
N
2
− CF
f
Where:
L = lower limit of median class
N = total frequency
CF = cumulative frequency before median class
f = frequency of median class
h = class width
🔹 Steps:
1️⃣ Calculate cumulative frequency
2️⃣ Find N/2
3️⃣ Find median class (where CF ≥ N/2)
4️⃣ Apply formula
Example Calculation
Total N = 35
N/2 = 17.5
[Link] 64/81
5/13/26, 6:42 PM Data Science Process
L = 20
CF = 13
f = 12
h = 10
17.5 − 13
M edian = 20 + ( ) × 10
12
M edian = 20 + (4.5/12) × 10
M edian ≈ 23.75
📊 Applications of Median
1️⃣ Income distribution
2️⃣ Salary analysis
3️⃣ Property price analysis
4️⃣ Skewed data analysis
5️⃣ Medical statistics
✅ Advantages of Median
1️⃣ Not affected by extreme values
2️⃣ Simple to calculate
3️⃣ Suitable for skewed data
4️⃣ Can be used for open-ended classes
5️⃣ Good for ordinal data
❌ Disadvantages of Median
1️⃣ Does not use all values
2️⃣ Not suitable for algebraic calculations
3️⃣ Difficult in large data
4️⃣ Less stable than mean
5️⃣ Cannot apply further statistical analysis easily
[Link] 65/81
5/13/26, 6:42 PM Data Science Process
📌 Important Differences
Mean Median
📌 What is Mode?
Mode is the value that occurs most frequently in a dataset.
Example:
Marks (x) Frequency (f)
10 2
20 5
30 3
40 1
👉 Highest frequency = 5
👉 Corresponding value = 20
✔ Mode = 20
Example:
[Link] 67/81
5/13/26, 6:42 PM Data Science Process
Class Frequency
0–10 5
10–20 8
20–30 12
30–40 10
👉 Highest frequency = 12
👉 Modal class = 20–30
2f1 − f0 − f2
Where:
L = lower limit of modal class
f₁ = frequency of modal class
f₀ = frequency before modal class
f₂ = frequency after modal class
h = class width
Example Calculation
Modal class = 20–30
L = 20
f₁ = 12
f₀ = 8
f₂ = 10
h = 10
12 − 8
M ode = 20 + ( ) × 10
2(12) − 8 − 10
[Link] 68/81
5/13/26, 6:42 PM Data Science Process
4
M ode = 20 + ( ) × 10
24 − 18
M ode = 20 + (4/6) × 10
M ode ≈ 26.67
📊 Applications of Mode
1️⃣ Market demand analysis
2️⃣ Fashion trends
3️⃣ Most common salary group
4️⃣ Most sold product
5️⃣ Customer preference analysis
✅ Advantages of Mode
1️⃣ Easy to find
2️⃣ Not affected by extreme values
3️⃣ Suitable for categorical data
4️⃣ Can be used for open-ended classes
5️⃣ Best for most frequent item detection
❌ Disadvantages of Mode
1️⃣ Not based on all observations
2️⃣ May have more than one mode (bi-modal)
3️⃣ Not suitable for algebraic calculations
4️⃣ Less stable
5️⃣ Difficult in irregular data
[Link] 69/81
5/13/26, 6:42 PM Data Science Process
📌 Important Relationship
For moderately skewed data:
[Link] 70/81
5/13/26, 6:42 PM Data Science Process
📌 What is Dispersion?
Dispersion means spread of data around the central value (mean/median).
📌 What is Variation?
Variation is the amount of difference among data values.
Example:
[Link] 71/81
5/13/26, 6:42 PM Data Science Process
📊 Measures of Dispersion
There are two types:
1️⃣ Range
📖 Formula:
Range = M aximum − M inimum
Example:
10, 20, 30, 40
Range = 40 - 10 = 30
✅ Advantages
Simple
Easy to calculate
❌ Disadvantages
Uses only 2 values
Affected by outliers
QD = (Q3 − Q1)/2
Advantage:
Less affected by extreme values
Disadvantage:
Ignores 50% data
∑ ∣x − x
ˉ∣
MD =
4️⃣ Variance
2 ˉ )2
∑(x − x
σ =
N
👉 Square of standard deviation.
N
👉 Most widely used measure of dispersion.
M ean
👉 Used to compare two datasets.
[Link] 73/81
5/13/26, 6:42 PM Data Science Process
📊 Python Example
Using Pandas (created by Wes McKinney)
Python Run
import pandas as pd
📊 Applications of Dispersion
1️⃣ Risk analysis in finance
2️⃣ Quality control
3️⃣ Income inequality measurement
4️⃣ Educational performance analysis
5️⃣ Machine learning preprocessing
📌 Comparison Table
Measure Uses All Data Affected by Outliers Best For
[Link] 74/81
5/13/26, 6:42 PM Data Science Process
range
📌 Definition
[Link] 75/81
5/13/26, 6:42 PM Data Science Process
Range is the difference between the largest value and the smallest value in a dataset.
📐 Formula
Range = M aximum − M inimum
Maximum = 25
Minimum = 5
Range = 25 − 5 = 20
0 – 10 5
10 – 20 8
20 – 30 7
Minimum value = 0
Maximum value = 30
Range = 30 − 0 = 30
📌 Types of Range
1️⃣ Absolute Range
[Link] 76/81
5/13/26, 6:42 PM Data Science Process
✅ Advantages of Range
✔ Very simple to calculate
✔ Quick idea of spread
✔ Useful in quality control
❌ Disadvantages of Range
✖ Uses only 2 values
✖ Affected by extreme values (outliers)
✖ Not reliable for detailed analysis
📊 Graphical Meaning
Small Range → Data close together
Large Range → Data widely spread
📌 Practical Uses
Temperature variation
Share market daily high & low
Production quality checking
[Link] 77/81
5/13/26, 6:42 PM Data Science Process
Range is the simplest measure of dispersion. It is defined as the difference between the
maximum and minimum values in a dataset. It provides a quick idea of variability but is
highly affected by extreme values. Therefore, it is less reliable than standard deviation for
detailed statistical analysis.
🔥 Viva Points
Range uses only max & min
Highly affected by outliers
Simplest dispersion measure
Formula: Max – Min
📌 Definition
Standard Deviation (S.D.) is the square root of variance.
It measures how much data values deviate (spread) from the mean.
[Link] 78/81
5/13/26, 6:42 PM Data Science Process
N
Where:
x = individual values
ˉ = mean
x
N = total number of observations
10 -20 400
20 -10 100
30 0 0
40 10 100
50 20 400
∑(x − x
ˉ)2 = 1000
[Link] 79/81
5/13/26, 6:42 PM Data Science Process
1000
σ=
5
σ= 200
σ ≈ 14.14
N
👉 Faster in exams.
📊 Important Points
Standard deviation is always positive
It uses all observations
More reliable than range
Most important dispersion measure
✅ Advantages
✔ Uses all values
✔ Scientifically accurate
✔ Useful in research & analysis
✔ Base of many statistical methods
❌ Disadvantages
✖ Calculation is lengthy
✖ Affected by extreme values
✖ Difficult for large data without calculator
[Link] 80/81
5/13/26, 6:42 PM Data Science Process
🔥 Viva Questions
1. What is standard deviation?
2. Why do we square deviations?
3. Is S.D. always positive?
4. Which is better: Range or S.D.?
[Link] 81/81