EN VI

What Is Python? A Plain Guide for Data Analysts

By ··7 min read

Short answer

Python is a free, general-purpose programming language. Data analysts use it to clean messy files, combine several sources, repeat a report on new data and draw charts. It reads close to plain English, so a short script is easy to follow. For a quick one-off total, Excel is still faster, and for data already in a database, SQL is the first choice.

So far, our SQL posts have read data that already sits in a database. Real work often starts earlier or ends later than that. Picture a shared folder with a few hundred monthly exports, where each file has slightly different column names. A database query cannot help with those files yet. Python covers these steps, so we first say what it is and then look at the jobs it handles best.

What is Python?

Python is a general-purpose programming language. We write instructions as plain text, and Python runs them from top to bottom. Its syntax reads close to English, so even a beginner can often follow a short script. Python is free, and it runs on Windows, macOS and Linux. A script works like a recipe card, because anyone who follows the same steps on the same ingredients gets the same dish.

Why analysts use Python

Analysts use Python for four kinds of jobs.

  • Cleaning messy files, such as fixing column names, removing duplicate rows and standardising dates.
  • Combining sources, such as CSV files, Excel sheets and database tables in one table.
  • Repeating a report, which means running the same script on next month's data.
  • Charts and statistics, since mature libraries already exist for both.

Python takes longer to set up than a spreadsheet, but once a script works, we can run it again on a new file in seconds. For a quick one-off total, Excel is still faster. We therefore choose by how big and how repeated the job is.

A first look at Python code

To see how it reads, we take four order amounts and ask two questions. What is the total, and which orders are 10 million or more?

amounts = [15000000, 8000000, 12000000, 20000000]

print(sum(amounts))                  # 55000000
print(sum(amounts) / len(amounts))   # 13750000.0

big = [a for a in amounts if a >= 10000000]
print(big)                           # [15000000, 12000000, 20000000]

The first two lines use built-in functions, sum and len. The last line is a list comprehension, which is a short way to keep only the items that pass a test. We do not need any extra library for this.

Python, SQL and Excel: which one for which job

These tools overlap, so the useful question is which one fits the job at hand.

JobFirst choiceWhy
Read data that already sits in a databaseSQLThe database does the filtering, so less data moves
Clean a messy export of 500,000 rowsPythonRules are written once and applied to every row
Build a one-off chart for tomorrow's meetingExcelThe fastest route for a small table
Repeat the same weekly reportPythonThe same script runs on the new file

Where pandas fits

Plain Python handles lists and numbers well. For tables with thousands of rows, analysts add a library called pandas. It gives Python a table object, the DataFrame, with rows and columns like a SQL table. We use it in pandas Basics: Read, Filter and Group Data in Python.

Frequently asked questions

What is Python used for in data analysis?

Python is used to clean messy data, combine several sources, repeat reports automatically and produce charts and statistics.

Is Python harder to learn than SQL?

Python covers more ground, so it takes longer to learn fully. A beginner can still write useful analysis scripts after a few weeks of regular practice.

Do I need to install Python to start learning?

No. Browser-based notebooks run Python without any installation. Installing it on your own computer becomes worthwhile when you work with your own files.

References

Keep learning, step by step.

Each lesson in Learn has a business context, a runnable example and a result check, so you practise this habit on real questions.