Data Science Tutorial menu

Data Science Introduction

Data science means using data, programming and statistics to find useful answers and make better decisions.

What is Data Science?

Imagine Ayesha runs a bakery with three branches in Karachi. Every sale is saved by her billing software. That is a lot of data, but by itself it tells her nothing. A data scientist can use it to answer questions like:

  • Which items sell most on weekends?
  • Which branch is growing fastest?
  • How many cakes should we bake for next Friday?

Data science mixes three skills:

SkillWhy it is needed
ProgrammingTo load, clean and analyse data quickly
Statistics and mathsTo understand patterns and avoid wrong conclusions
Domain knowledgeTo ask the right questions about the business

The Steps of a Data Project

Most projects follow these steps:

  1. Ask a question: "Which product makes the most profit?"
  2. Collect data: from files, databases, websites or surveys
  3. Clean the data: fix missing values, typing mistakes and duplicates
  4. Explore: summarise, group and plot the data to find patterns
  5. Model (optional): build a machine learning model to predict something
  6. Communicate: share the result with charts and a clear explanation

Cleaning often takes the most time. Real data is messy.

Python Tools for Data Science

LibraryWhat it does
NumPyFast maths on arrays of numbers
pandasTables of data (DataFrames): loading, cleaning, grouping
matplotlibDrawing charts
seabornNicer statistical charts, built on matplotlib
scikit-learnMachine learning models
Jupyter NotebookWrite code, see results and charts step by step in the browser

Setting Up

Install Python from the official website, then install the libraries with pip:

Example

bash
pip install pandas numpy matplotlib scikit-learn jupyter

Start Jupyter Notebook:

Example

bash
jupyter notebook

A browser tab opens. Click New > Python 3 to create a notebook. Type code in a cell and press Shift + Enter to run it.

No installation? Google Colab gives you a free Jupyter notebook in the browser, with pandas and matplotlib already installed.

Plain Python vs pandas

You can analyse small data with plain Python:

Example

python
marks = [72, 85, 90, 64, 78]
print("Average:", sum(marks) / len(marks))
print("Highest:", max(marks))
Output
Average: 77.8
Highest: 90

But with real tables (names, cities, marks, dates), pandas is much easier. The same data as a pandas table, showing only students above 75:

Example

python
import pandas as pd

df = pd.DataFrame({
    "student": ["Ali", "Ayesha", "Bilal", "Sana", "Hamza"],
    "marks": [72, 85, 90, 64, 78],
})
print(df[df["marks"] > 75])
Output
  student  marks
1  Ayesha     85
2   Bilal     90
4   Hamza     78

The numbers on the left (1, 2, 4) are the index, the row labels pandas gives each row.

Data Science, AI and Machine Learning

These words are often mixed up:

  • Data analysis: looking at past data to understand what happened
  • Machine learning: programs that learn patterns from data to make predictions
  • Artificial intelligence (AI): the wider field of making computers do "smart" tasks
  • Data science: covers analysis, and often machine learning too

Exercise

Exercise

In a data science project, which step usually takes the most time?

Learn Data Science with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp