0% found this document useful (0 votes)
2 views26 pages

Data Analytics Python Session MSE 1

The document outlines a workshop on Data Analytics with Python, covering topics such as the basics of Python, data handling with libraries like Pandas and NumPy, and the ETL process. It emphasizes the importance of data cleaning, preprocessing, and visualization techniques using Matplotlib and Seaborn. The session concludes with a checklist of skills participants should acquire and potential next steps for further learning.

Uploaded by

noornoorsb0
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)
2 views26 pages

Data Analytics Python Session MSE 1

The document outlines a workshop on Data Analytics with Python, covering topics such as the basics of Python, data handling with libraries like Pandas and NumPy, and the ETL process. It emphasizes the importance of data cleaning, preprocessing, and visualization techniques using Matplotlib and Seaborn. The session concludes with a checklist of skills participants should acquire and potential next steps for further learning.

Uploaded by

noornoorsb0
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

Data Analytics with Python

Session 1: Python Basics, Pandas, ETL, Visualization

Instructor: Ghaith Hajji

MSE Workshops

February 28, 2026

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 1 / 26
Agenda

1 What is Data Analytics?


2 Why Python for data?
3 Libraries: Pandas, NumPy, Matplotlib, Seaborn
4 ETL: Extract, Transform, Load
5 Transform deep dive: cleaning and preprocessing
6 Save cleaned datasets to CSV
7 Visualization commands you must know

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 2 / 26
What is Data Analytics?

Data Analytics is the process of converting raw data into insights for decision-making.

Common goals:
Describe: What happened? (reports, dashboards)
Diagnose: Why did it happen? (comparisons, correlations)
Predict: What may happen? (models)
Prescribe: What should we do? (recommendations)

Raw Data → Clean Data → Analysis → Visualization → Decision

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 3 / 26
Why Python for Data Analytics?

Fast development: readable syntax, huge ecosystem


Data handling: Pandas for tabular data
Math and speed: NumPy arrays and vectorized operations
Visualization: Matplotlib and Seaborn
Career relevance: widely used in analytics, ML, and automation

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 4 / 26
Libraries in This Session

Pandas
DataFrames, cleaning, transformations, reading and writing CSV/Excel.

NumPy
Fast numerical computations, arrays, missing values, vectorization.

Matplotlib
Base plotting library: full control (line, bar, hist, scatter, etc.).

Seaborn
High-level statistical plots with clean defaults.

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 5 / 26
Python Essentials for Data Work

You need these basics:


Variables and types: int, float, str, bool
Lists, tuples, dicts
Conditionals: if / elif / else
Loops: for / while (avoid loops when using Pandas and NumPy)
Functions: def, parameters, return
Imports: import pandas as pd
import pandas as pd
import numpy as np
import [Link] as plt
import seaborn as sns

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 6 / 26
ETL: Extract, Transform, Load

Extract
Read data from sources: CSV, Excel, JSON, databases, APIs.

Transform
Clean and preprocess: missing values, duplicates, types, outliers, features.

Load
Save or export: cleaned CSV, database table, dashboard dataset.

ETL : E (read) → T (clean) → L(save)

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 7 / 26
Extract: Reading Data with Pandas

df = pd.read_csv("[Link]")
df = pd.read_excel("[Link]")
df = pd.read_json("[Link]")

[Link]()
[Link]
[Link]
[Link]()
[Link](include="all")

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 8 / 26
Pandas DataFrame Basics

data = {
"Name": ["Ali", "Sara", "Meryem"],
"Age": [20, 22, 21],
"Score": [14.5, 16.0, 13.0]
}
df = [Link](data)

df["Score"]
df[["Name", "Age"]]
[Link][0]
[Link][0]

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 9 / 26
Transform: Cleaning and Preprocessing

Typical Transform tasks:


Missing values (NaN)
Duplicates
Wrong data types
Inconsistent text (spaces, casing)
Outliers or invalid values
Feature engineering (new columns)

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 10 / 26
Transform: Missing Values

[Link]().sum()

df2 = [Link](subset=["Age", "Score"])

df["Age"] = df["Age"].fillna(df["Age"].median())
df["Name"] = df["Name"].fillna("Unknown")

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 11 / 26
Transform: Duplicates

[Link]().sum()
df = df.drop_duplicates()

df = df.drop_duplicates(subset=["ID"], keep="first")

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 12 / 26
Transform: Fix Data Types

[Link]

df["Price"] = pd.to_numeric(df["Price"], errors="coerce")


df["Date"] = pd.to_datetime(df["Date"], errors="coerce")

df["Category"] = df["Category"].astype("category")

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 13 / 26
Transform: Text Cleaning

df["City"] = df["City"].[Link]()
df["City"] = df["City"].[Link]()

df["Gender"] = df["Gender"].replace({"M": "Male", "F": "Female"})

df["Installs"] = (df["Installs"]
.[Link]("+", "", regex=False)
.[Link](",", "", regex=False)
.astype(int))

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 14 / 26
Transform: Filtering, Sorting, New Columns

df_high = df[df["Score"] >= 15]


df_sorted = df.sort_values("Score", ascending=False)

df["Passed"] = df["Score"] >= 10


df["Score_z"] = (df["Score"] - df["Score"].mean()) / df["Score"].std()

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 15 / 26
Transform: GroupBy (Most Used in Analytics)

summary = ([Link]("Category")
.agg(avg_rating=("Rating", "mean"),
total_reviews=("Reviews", "sum"),
total_installs=("Installs", "sum"))
.reset_index())

summary.sort_values("total_installs", ascending=False).head(10)

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 16 / 26
Load: Saving Cleaned Data to CSV

df.to_csv("cleaned_data.csv", index=False)
summary.to_csv("category_summary.csv", index=False)

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 17 / 26
NumPy Essentials

arr = [Link]([1, 2, 3, 4])


[Link]()
[Link]()
[Link](), [Link]()

arr2 = arr * 10 + 5
arr[arr > 2]

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 18 / 26
Visualization: Matplotlib vs Seaborn

Matplotlib: low-level control, everything is customizable


Seaborn: high-level plots for faster insights
Rule of thumb:
Start with Seaborn for exploration
Use Matplotlib for final polishing

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 19 / 26
Must-Know Plot Types

Histogram: distribution of a numeric column


Bar plot: compare categories
Scatter plot: relationship between two variables
Line plot: trends (often over time)
Box plot: spread and outliers
Heatmap: correlation matrix

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 20 / 26
Matplotlib: Common Commands

[Link](figsize=(8, 5))
[Link](df["Rating"].dropna(), bins=20)
[Link]("Rating distribution")
[Link]("Rating")
[Link]("Count")
[Link]()

[Link](figsize=(8, 5))
[Link](df["Reviews"], df["Rating"])
[Link]("Rating vs Reviews")
[Link]("Reviews")
[Link]("Rating")
[Link]()

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 21 / 26
Seaborn: Common Commands

sns.set_theme()

[Link](figsize=(8, 5))
[Link](data=df, x="Category")
[Link]("Count per Category")
[Link](rotation=45)
[Link]()

[Link](figsize=(8, 5))
[Link](data=df, x="Reviews", y="Rating", hue="Category")
[Link]("Rating vs Reviews by Category")
[Link]()

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 22 / 26
Seaborn: Boxplot and Heatmap

[Link](figsize=(8, 5))
[Link](data=df, x="Category", y="Rating")
[Link]("Rating spread by Category")
[Link](rotation=45)
[Link]()

num = df.select_dtypes(include="number")
[Link](figsize=(7, 5))
[Link]([Link](), annot=True, fmt=".2f")
[Link]("Correlation heatmap")
[Link]()

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 23 / 26
Mini ETL Example (End-to-End)

import pandas as pd

# Extract
df = pd.read_csv("[Link]")
# Transform
df = df.drop_duplicates()
df["Installs"] = (df["Installs"]
.[Link]("+", "", regex=False)
.[Link](",", "", regex=False))
df["Installs"] = pd.to_numeric(df["Installs"], errors="coerce")
df["Rating"] = pd.to_numeric(df["Rating"], errors="coerce")
df["Rating"] = df["Rating"].fillna(df["Rating"].median())
# Load
df.to_csv("apps_cleaned.csv", index=False)

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 24 / 26
Practice Checklist

By the end of this session, you can:


1 Read a CSV into a DataFrame
2 Inspect data: head, info, describe
3 Clean: missing values, duplicates, types, text
4 Create new columns and filter or sort rows
5 Summarize using groupby
6 Save cleaned data to CSV
7 Plot: histogram, bar, scatter, boxplot, heatmap

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 25 / 26
Next Steps

Next sessions could include:


Merging and joining datasets
Outliers, scaling, encoding
A mini-project with a real dataset + short report

Questions?

Instructor: Ghaith Hajji (MSE Workshops) Data Analytics with Python February 28, 2026 26 / 26

You might also like