Data Science Beginner Course
Learn how to turn raw data into decisions. Master Python, NumPy, Pandas, data cleaning, statistics, and visualization — then apply it all in a real dataset capstone project.
Start LearningWhat Is Data Science?
12 minWhat you'll learn
- Understand the data science workflow
- Learn why data drives decisions
- See real-world applications
Data science is the art of turning raw data into decisions. The workflow is: ask a question, collect data, clean it, explore it, model it, and communicate insights. Every recommendation you see — Netflix suggestions, Amazon product picks, Spotify playlists — is data science in action. In this course you'll learn the same Python tools professionals use every day.
# The data science workflow
workflow = [
'Ask', 'Collect', 'Clean',
'Explore', 'Model', 'Communicate'
]
print(' → '.join(workflow))
Try it yourself
List three industries where data science is used daily.
E-commerce, healthcare, finance, social media, transport.
Setting Up Python for Data Science
14 minWhat you'll learn
- Install NumPy, Pandas, Matplotlib
- Understand Jupyter notebooks
- Import libraries correctly
Python's data science power comes from its ecosystem: NumPy for numbers, Pandas for tables, Matplotlib for charts. The standard way to import them is with short aliases — np, pd, plt — that you'll see in every tutorial and codebase. Jupyter Notebook is the interactive environment where data scientists experiment, but plain .py files work too.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
print('NumPy', np.__version__)
print('Pandas', pd.__version__)
Try it yourself
Import pandas with the standard alias and print its version.
import pandas as pd print(pd.__version__)
NumPy Arrays: The Foundation
18 minWhat you'll learn
- Create NumPy arrays
- Understand vectorized operations
- Reshape and slice arrays
NumPy arrays are like Python lists but far more powerful — they're fast, memory-efficient, and support vectorized operations that work on entire arrays at once. Instead of looping through a million numbers, you write one operation that applies to all of them simultaneously. This speed is why every data science library is built on NumPy.
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print('Array:', arr)
print('Doubled:', arr * 2)
print('Mean:', arr.mean())
print('Shape:', arr.shape)
Try it yourself
Create an array of [10,20,30] and add 5 to every element.
arr = np.array([10, 20, 30]) arr + 5 # [15, 25, 35]
Pandas Series
14 minWhat you'll learn
- Create Series objects
- Access values by index
- Perform quick statistics
A Pandas Series is a one-dimensional labeled array — think of a column in a spreadsheet. Each value has an index label. You can create one from a list, give it custom labels, and instantly compute statistics like sum, mean, min, and max. Series is the building block for DataFrames, the main data structure you'll use from here on.
import pandas as pd
temps = pd.Series([22, 25, 19, 30, 27],
index=['Mon','Tue','Wed','Thu','Fri'])
print(temps)
print('Average:', temps.mean())
print('Hottest:', temps.max())
Try it yourself
Create a Series of [1,2,3] with index ['a','b','c'].
s = pd.Series([1, 2, 3], index=['a', 'b', 'c']) print(s)
Pandas DataFrames
18 minWhat you'll learn
- Create DataFrames from dicts
- Select rows and columns
- Understand shape and info
A DataFrame is a two-dimensional table — rows and columns, exactly like Excel or a SQL table. You build one from a dictionary where each key becomes a column. It's THE core data structure in data science: load data into a DataFrame, and you can filter, sort, group, aggregate, and visualize with a few lines of code.
import pandas as pd
data = {
'name': ['Ali', 'Sara', 'Omar'],
'age': [25, 30, 22],
'city': ['Lahore', 'Karachi', 'Islamabad']
}
df = pd.DataFrame(data)
print(df)
print('Shape:', df.shape)
print(df['name'])
Try it yourself
Create a DataFrame with columns 'fruit' and 'price' (3 rows).
df = pd.DataFrame({'fruit':['apple','banana','mango'], 'price':[2,1,3]})Reading CSV Files
16 minWhat you'll learn
- Load data with read_csv
- Inspect data with head()
- Check missing values
CSV (comma-separated values) is the universal data exchange format — every dataset you download from Kaggle or government portals is likely a CSV. pd.read_csv() loads it into a DataFrame in one line. Then head() shows the first rows, info() shows the schema, and isnull().sum() reveals missing data. This is the first thing you do with any real dataset.
import pandas as pd
df = pd.read_csv('sales.csv')
print(df.head())
print(df.info())
print('Missing:', df.isnull().sum())
Try it yourself
Load a CSV and print its first 3 rows.
df = pd.read_csv('data.csv')
print(df.head(3))Data Cleaning Basics
20 minWhat you'll learn
- Handle duplicates
- Fix data types
- Rename columns
Real data is messy — duplicate rows, wrong types, cryptic column names. Cleaning is removing duplicates with drop_duplicates(), converting types with astype(), and renaming columns with rename(). It's unglamorous, but clean data is the difference between reliable analysis and garbage results. This is where data scientists spend most of their time.
import pandas as pd
df = pd.DataFrame({'Name':['Ali','Ali','Sara'],
'Age':['25','30','22']})
df = df.drop_duplicates()
df['Age'] = df['Age'].astype(int)
df = df.rename(columns={'Name':'full_name'})
print(df)
Try it yourself
Drop duplicate rows from a DataFrame.
df = df.drop_duplicates()
Handling Missing Values
20 minWhat you'll learn
- Detect missing data
- Drop or fill missing values
- Understand the trade-offs
Missing values (NaN) are everywhere in real data. You either drop rows with dropna() or fill them with fillna() — using a mean, median, or a placeholder. Dropping loses data; filling can introduce bias. The right choice depends on context: a missing phone number is fine to drop; a missing salary might need careful imputation.
import pandas as pd
import numpy as np
df = pd.DataFrame({'score':[85, np.nan, 92, np.nan, 78]})
print('Original mean:', df['score'].mean())
df_filled = df.fillna(df['score'].mean())
print(df_filled)
Try it yourself
Fill missing values with 0.
df = df.fillna(0)
Data Visualization with Matplotlib
20 minWhat you'll learn
- Create line and bar charts
- Add titles and labels
- Customize plots
Matplotlib is Python's foundational plotting library. A simple line or bar chart turns numbers into insights you can see instantly. The pattern is: create a figure, plot your data, add labels, and show it. Every other visualization library builds on this foundation, so understanding Matplotlib unlocks everything else.
import matplotlib.pyplot as plt
months = ['Jan', 'Feb', 'Mar', 'Apr']
sales = [120, 150, 130, 170]
plt.bar(months, sales, color='#059669')
plt.title('Monthly Sales')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.show()
Try it yourself
Create a line plot of [1,3,2,4].
plt.plot([1, 3, 2, 4]) plt.show()
More Charts: Histograms & Pie
18 minWhat you'll learn
- Visualize distributions with histograms
- Show proportions with pie charts
- Pick the right chart
Choosing the right chart matters. Histograms show how values are distributed — where most data clusters, whether it's skewed. Pie charts show proportions of a whole. Bar charts compare categories. The skill is knowing which question each chart answers and reaching for the right one.
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
scores = np.random.normal(70, 10, 1000)
plt.hist(scores, bins=20, color='#059669', edgecolor='white')
plt.title('Score Distribution')
plt.xlabel('Score')
plt.ylabel('Frequency')
plt.show()
Try it yourself
Create a histogram of [1,1,2,3,3,3,4].
plt.hist([1,1,2,3,3,3,4]) plt.show()
Introduction to Statistics
18 minWhat you'll learn
- Understand descriptive statistics
- Learn population vs sample
- Grasp why statistics matters
Statistics is the math behind data science — how we summarize, infer, and make decisions from data. Descriptive statistics (mean, median, spread) describe what you have; inferential statistics helps you generalize to what you don't. Without statistics, data science is just guessing with extra steps.
import numpy as np
data = [10, 12, 15, 18, 20, 20, 25]
print('Mean:', np.mean(data))
print('Median:', np.median(data))
print('Std:', np.std(data))
print('Range:', max(data) - min(data))
Try it yourself
Compute the median of [1,2,3,4,100].
np.median([1,2,3,4,100]) # 3
Mean, Median & Mode
16 minWhat you'll learn
- Calculate central tendency
- Choose the right metric
- Detect skewness
Central tendency tells you the 'typical' value. Mean is the average (sensitive to outliers). Median is the middle value (robust). Mode is the most frequent. In skewed data — like income, where a few billionaires inflate the average — the median is usually more honest than the mean.
import numpy as np
from scipy import stats
income = [30000, 32000, 35000, 38000, 40000, 1000000]
print('Mean:', np.mean(income))
print('Median:', np.median(income))
print('Mode:', stats.mode(income).mode)
Try it yourself
Why is median better than mean for house prices?
A few luxury homes inflate the mean; median reflects the typical home.
Data Distribution & Outliers
18 minWhat you'll learn
- Identify normal vs skewed data
- Detect outliers
- Understand standard deviation
Distribution describes how data spreads out. Normal distribution is the bell curve — symmetric, most values near the middle. Skewed data leans left or right. Outliers sit far from the rest and can distort analysis. Standard deviation measures spread: low means tight clustering, high means wide scatter.
import numpy as np
data = [10, 12, 11, 13, 12, 11, 100] # 100 is an outlier
mean = np.mean(data)
std = np.std(data)
outlier_threshold = mean + 2 * std
outliers = [x for x in data if x > outlier_threshold]
print('Outliers:', outliers)
Try it yourself
Find the outlier in [1,2,2,3,50].
50 is the outlier.
Correlation
18 minWhat you'll learn
- Understand correlation coefficient
- Distinguish correlation from causation
- Interpret r values
Correlation measures how two variables move together, scored from -1 to +1. +1 means perfectly together, -1 means opposite, 0 means no relationship. But correlation is NOT causation: ice cream sales and drowning both rise in summer, but ice cream doesn't cause drowning — a third variable (heat) drives both.
import pandas as pd
df = pd.DataFrame({
'hours_studied': [1, 2, 3, 4, 5],
'exam_score': [50, 58, 70, 82, 90]
})
print(df.corr())
Strong positive correlation
Try it yourself
What does a correlation of -0.9 mean?
As one variable increases, the other decreases strongly.
Data Wrangling: Filter & Sort
20 minWhat you'll learn
- Filter rows with conditions
- Sort by columns
- Select specific columns
Wrangling is shaping data into the form you need. Filtering keeps rows meeting a condition (sales > 100). Sorting orders rows by a column. Selecting grabs specific columns. These three operations — filter, sort, select — are the daily bread of data work, and Pandas makes each a one-liner.
import pandas as pd
df = pd.DataFrame({
'product': ['A','B','C','D'],
'sales': [120, 80, 200, 150],
'region': ['East','West','East','South']
})
high = df[df['sales'] > 100]
sorted_df = df.sort_values('sales', ascending=False)
print(high)
print(sorted_df[['product','sales']])
Try it yourself
Filter rows where age > 25 from a DataFrame.
adults = df[df['age'] > 25]
Grouping & Aggregation
20 minWhat you'll learn
- Group data by categories
- Apply aggregations like sum/mean
- Create summary tables
Grouping splits data by category, then aggregates each group — average salary by department, total sales by region, max temperature by month. The pattern df.groupby('column').agg(...) is how you turn thousands of raw rows into a compact, meaningful summary. It's arguably the most important Pandas operation for real analysis.
import pandas as pd
df = pd.DataFrame({
'region': ['East','West','East','West'],
'sales': [100, 150, 200, 120]
})
summary = df.groupby('region').agg(
total=('sales', 'sum'),
average=('sales', 'mean')
)
print(summary)
Try it yourself
Group by 'department' and sum 'salary'.
df.groupby('department')['salary'].sum()Intro to Seaborn
18 minWhat you'll learn
- Create beautiful statistical plots
- Use seaborn's high-level API
- Make publication-ready charts
Seaborn builds on Matplotlib but makes statistical plots beautiful by default. Instead of manually styling every element, you write one line and get a clean, colored, labeled chart. For data exploration and reports, Seaborn is the fastest path from data to insight.
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset('tips')
sns.barplot(data=tips, x='day', y='total_bill', palette='viridis')
plt.title('Average Bill by Day')
plt.show()
Try it yourself
Create a Seaborn histogram of a dataset.
sns.histplot(data=df, x='value') plt.show()
Exploratory Data Analysis (EDA)
22 minWhat you'll learn
- Understand the EDA process
- Generate summary statistics
- Spot patterns before modeling
EDA is the detective phase: before building any model, you explore the data to understand its shape, find anomalies, and form hypotheses. The toolkit: describe() for summary stats, histograms for distributions, correlation matrices for relationships, and boxplots for outliers. EDA done well makes everything after it easier.
import pandas as pd
df = pd.read_csv('data.csv')
print(df.describe())
print('\nMissing values:')
print(df.isnull().sum())
print('\nCorrelations:')
print(df.corr(numeric_only=True))
Try it yourself
Use describe() on a DataFrame and find the max value of one column.
df.describe().loc['max']
Data Storytelling
16 minWhat you'll learn
- Communicate insights clearly
- Choose the right visualization
- Write compelling narratives
Analysis without communication is wasted effort. Data storytelling means turning numbers into a clear narrative: what's the key finding, why does it matter, and what should happen next? A good chart plus a clear headline beats a dashboard of confusing visuals. This is what separates analysts from data scientists who influence decisions.
# A good data story has: # 1. A clear question # 2. A single key insight # 3. One chart that proves it # 4. A recommended action insight = 'Sales rose 40% after the marketing campaign' action = 'Double the campaign budget next quarter'
Try it yourself
Write a one-sentence insight about sales dropping in winter.
Winter sales fell 30% — likely seasonality — so stock accordingly.
Capstone: Analyze a Real Dataset
45 minWhat you'll learn
- Apply the full data science workflow
- Clean, explore, and visualize data
- Produce a summary report
Time to put it all together. You'll load a real dataset (start with Seaborn's built-in tips or iris), clean it, explore with describe() and groupby, visualize distributions and relationships, and write a short summary of findings. This complete mini-project proves you can do the full workflow end to end.
import seaborn as sns
import pandas as pd
# Load, clean, explore, visualize
df = sns.load_dataset('tips')
print(df.head())
print(df.describe())
print(df.groupby('day')['total_bill'].mean())
sns.heatmap(df.corr(numeric_only=True), annot=True, cmap='YlGnBu')
plt.show()
Try it yourself
Find which day has the highest average tip.
df.groupby('day')['tip'].mean().idxmax()You've completed all 20 lessons. Ready for more?
Continue to Data Science Intermediate for machine learning, feature engineering, and advanced analysis.