सामग्री पर जाएँ

लेसन 3 · Getting Started

Your EDA Toolkit

Meet the tools for exploratory data analysis: Python, pandas, Matplotlib, SQL and notebooks, with runnable examples and habits for reproducible work.

You can explore data with a spreadsheet, a programming language, a database or a visual analytics product. The thinking is the same in all of them. This tutorial uses Python and SQL because they are free to learn, they record every step and they work for both small and fairly large tables.

You will see the same tiny table handled by plain Python, pandas, SQL and Matplotlib. Knowing what each one is good at helps you pick the right tool.

The four tools

Tool Strength Typical EDA use
Python standard library No installation, every step visible Learning how a summary is computed
pandas Fast table operations Loading, filtering, grouping, summarizing
Matplotlib Detailed control of charts Histograms, scatter plots, line charts
SQL Works where the data lives Counting and aggregating database tables

Libraries such as seaborn build on Matplotlib and make some statistical charts shorter to write. See the seaborn tutorial when you want that.

Installing on your computer

You can run every example here in the browser. For your own work, create a virtual environment and install the packages:

Terminal
python -m venv .venv
# Activate it: .venv\Scripts\activate (Windows) or source .venv/bin/activate (macOS, Linux)
python -m pip install pandas matplotlib jupyterlab
jupyter lab

The pandas setup lesson explains these steps in more detail.

One question, plain Python

Data in plain Python is often a list of dictionaries: one dictionary per row. The question here is simple: what is the total quantity sold per product?

Python Totals with the standard library

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You can see each step. That is great for learning and for custom checks, but it becomes long when you have many columns.

The same data in pandas

pandas stores a table in a DataFrame. One line replaces the loop.

Python Totals with pandas

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If the syntax is new, read the pandas introduction alongside this course.

The same question in SQL

When data sits in a database, summarize it there and bring back only what you need. The block below creates its own table.

SQL Totals with SQL

Press Run (or Ctrl + Enter) to see the result here.

All three give the same quantities. Checking a key number with a second method is a cheap and powerful habit.

A first chart

Matplotlib draws figures. Give every chart a title and axis labels, even while exploring. You will thank yourself when you return later.

Python A simple bar chart

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notebooks and scripts

A notebook mixes code, output and notes in cells. It suits exploration because you see each result at once. Its risk is hidden state: if you run cells out of order, the output on screen may not match the code from top to bottom.

Before you share a notebook, restart it and run all cells in order. When a step becomes stable, such as loading and basic cleaning, move it into a function in a .py file that both your notebook and your tests can use.

Habits that make work reproducible

  • Never edit the raw file. Read it, and save changed versions under new names.
  • Do changes in code, so that you can repeat and review them.
  • Fix random seeds when you sample or simulate.
  • Record versions of the data and the main libraries.
  • Use relative paths so the project can move to another computer.
Python A seeded sample is repeatable

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Using AI assistants

An AI assistant can suggest code or explain an error. Treat its output as a draft. Run it, check it on a few rows that you can verify by hand, and make sure that it did not silently drop data. Never send private, personal or company data to a tool that your organization has not approved. The prompt engineering tutorial can help you ask clearer questions.

Start with the simplest tool that answers the question. A five-line SQL query can be better than a long notebook.

When a spreadsheet is enough

Spreadsheets are fine for a quick look at a small table, and many people who receive your results will use one. Their weakness for exploration is that manual edits leave little trace. Sorting only one column, overwriting a formula or dragging a range that stops too early can change results without any warning. Code makes each step visible, so you can read it again and ask whether it was right.

If you must work in a spreadsheet, keep one untouched copy of the original, do your work on separate sheets and note every manual change.

A suggested project layout

A tidy folder helps you find things later and keeps raw data safe:

TEXT
my-analysis/
  data/raw/        original files, never edited
  data/processed/  files your code creates
  notebooks/       exploration
  src/             reusable functions
  notes.md         questions, decisions, open points

Adapt the names to your team's habits. Before you put anything in version control, check that the folder does not include private data, passwords or access keys. A .gitignore file can exclude data folders, but you should still review what you commit.

Which tool for which step?

Step A sensible first choice
Count rows in a large database table SQL
Read a CSV and inspect columns pandas
Verify one formula by hand Plain Python
See the shape of a column A Matplotlib histogram

There is no prize for using only one tool. Move data to the next tool when the current one makes a question awkward.

Try it yourself

In the pandas example, add a store column and group by both store and product. Then write the same query in SQL and compare the totals row by row.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is a pandas DataFrame?

    A DataFrame is the main table structure in pandas.
  2. 2. What is a common risk of notebooks?

    Restart and run all cells to confirm that the results come from the code as written.
  3. 3. Why is SQL useful for EDA?

    Summarizing in the database is often efficient and keeps raw data where it belongs.
  4. 4. How should you treat code suggested by an AI assistant?

    Code can run and still be wrong, for example by dropping rows.

Summary

  • Python, pandas, Matplotlib and SQL cover most everyday exploration.
  • Cross-checking a key number with a second method catches mistakes.
  • Notebooks are handy, but restart and run them in order before sharing.
  • Keep raw data unchanged, script your changes and fix random seeds.
  • Protect private data and verify any suggested code.

Next: Loading Data and Taking a First Look

आपकी प्रगति इसी ब्राउज़र में सेव होती है। खाते की ज़रूरत नहीं है।