Data AnalyticsPandas & NumPybeginner
Updated:

Pandas Tutorial: A Beginner's Introduction

5 min read

Pandas is the core Python library for data analysis. Learn what it is, how to build a DataFrame, and how to run your first real inspection on tabular data.

TL;DR – Quick Answer

Pandas is the standard Python library for working with tabular data. Its two core objects are the Series (one column) and the DataFrame (a full table of rows and columns). You import it as pd, load data into a DataFrame, then inspect, filter, group and summarize it. It is the first tool almost every data analyst learns after basic Python.

On This Page

Pandas is the library that turns Python into a serious data analysis tool. If you have ever sorted, filtered or summarized data in a spreadsheet, pandas does all of that in code you can save, repeat and scale to millions of rows. It is the first thing almost every data analyst reaches for, and this tutorial gets you from zero to your first real DataFrame analysis.

The name comes from "panel data", a term for multi-dimensional datasets. What matters day to day is simpler: pandas gives you a table object called a DataFrame that you can load, clean, reshape and analyze with short, readable commands. Master this one library and a huge share of analyst work becomes approachable.

What pandas is and why analysts use it

Raw Python can hold data in lists and dictionaries, but it has no built-in idea of a table with named columns and typed values. Pandas fills that gap. It gives you two structures: the Series, a single labelled column, and the DataFrame, a full grid of rows and columns where each column can hold a different type such as numbers, text or dates.

Analysts use pandas because it replaces slow, manual spreadsheet work with repeatable code. When a monthly report needs the same twelve steps every time, a pandas script runs them identically in seconds. It reads almost any file format, handles missing values gracefully, and connects cleanly to charting libraries and databases. That combination is why pandas sits at the centre of the Python data stack.

Installing and importing pandas

If you use Anaconda, pandas is already installed. Otherwise install it once from your terminal:

pip install pandas

By universal convention pandas is imported with the alias pd. Every tutorial, answer and codebase you will ever read uses this alias, so adopt it from day one:

import pandas as pd
print(pd.__version__)
2.2.2

Building your first DataFrame

You do not need a file to start. You can build a DataFrame directly from a Python dictionary, where each key becomes a column name and each list becomes that column's values. This small inline dataset is illustrative sample data, not real records:

import pandas as pd

data = {
    "name": ["Aarti", "Bhaskar", "Chitra", "Devan", "Esha"],
    "city": ["Hyderabad", "Hyderabad", "Bengaluru", "Pune", "Bengaluru"],
    "age": [24, 31, 28, 45, 22],
    "salary": [48000, 65000, 52000, 90000, 47000],
}

df = pd.DataFrame(data)
print(df)
      name       city  age  salary
0    Aarti  Hyderabad   24   48000
1  Bhaskar  Hyderabad   31   65000
2   Chitra  Bengaluru   28   52000
3    Devan       Pune   45   90000
4     Esha  Bengaluru   22   47000

The numbers 0 to 4 on the left are the index, an automatic row label pandas creates for you. The row of names across the top are the column labels. Every pandas operation works in terms of this index-and-columns grid.

Inspecting data the way analysts do

The first thing you do with any new dataset is look at it. Pandas gives you a small toolkit of inspection methods that you will use in that order on almost every dataset you touch:

print(df.head(3))     # first 3 rows
print(df.shape)       # (rows, columns)
print(df.columns.tolist())
print(df.dtypes)
      name       city  age  salary
0    Aarti  Hyderabad   24   48000
1  Bhaskar  Hyderabad   31   65000
2   Chitra  Bengaluru   28   52000
(5, 4)
['name', 'city', 'age', 'salary']
name      object
city      object
age        int64
salary     int64
dtype: object

head() shows the top rows, shape reports the size as a (rows, columns) tuple, columns lists the column names, and dtypes tells you the data type pandas inferred for each column. Text columns show up as object, whole numbers as int64. Getting the dtypes right early prevents a whole category of bugs later.

For a fast statistical overview of every numeric column, describe() is unbeatable:

print(df.describe())
             age        salary
count   5.000000      5.000000
mean   30.000000  60400.000000
std     9.246621  17669.181...
min    22.000000  47000.000000
25%    24.000000  48000.000000
50%    28.000000  52000.000000
75%    31.000000  65000.000000
max    45.000000  90000.000000

In one line you get count, mean, standard deviation, minimum, maximum and the quartiles for every numeric column. This is often the very first command an analyst runs to sense-check a fresh dataset.

A first taste of analysis

Inspection leads naturally into questions. Selecting a single column gives you a Series, and Series have handy methods built in:

print(df["salary"].mean())
print(df["city"].value_counts())
60400.0
city
Hyderabad    2
Bengaluru    2
Pune         1
Name: count, dtype: int64

value_counts() is one of the most-used methods in all of pandas: it counts how many times each value appears. Here it instantly tells you the city distribution. From here you can filter rows, group by a column and merge tables, which are the topics of the next tutorials in this series.

Common mistakes

  • Forgetting the pd alias. Writing pandas.DataFrame(...) works only if you imported the full name. Stick to import pandas as pd and use pd everywhere.
  • Confusing a Series with a DataFrame. df["salary"] returns a Series (one column), while df[["salary"]] with double brackets returns a one-column DataFrame. Some methods exist on only one of them.
  • Editing a slice and expecting the original to change. Pandas sometimes returns a view and sometimes a copy. When you mean to modify data, assign back explicitly with df["col"] = ... rather than relying on chained indexing.
  • Ignoring dtypes. A column of numbers stored as text (object) will not compute a mean correctly. Check dtypes early and convert when needed.

In interviews

Data analyst interviews often open with "walk me through how you'd explore a new dataset." A strong answer names the exact methods: head() to eyeball the data, shape for size, info() and dtypes for structure and types, describe() for distributions, and value_counts() for categorical columns. Interviewers also ask you to explain the difference between a Series and a DataFrame, so be ready to say a DataFrame is a collection of Series sharing one index. Being able to narrate this workflow confidently signals real hands-on experience.

Where this fits in your learning path

This introduction is the front door to the whole data analytics learning path. From here, go deeper into the two core structures in pandas Series and DataFrame, then learn to pull in real files with reading CSV and Excel files. Those three together give you everything you need to start loading and exploring datasets on your own, and they map directly onto the day-one skills expected in the data analyst role.

Frequently Asked Questions

What is pandas used for?
Pandas is used for loading, cleaning, transforming and analyzing tabular data in Python. Analysts use it to read CSV and Excel files, filter and group rows, compute summaries, and prepare data for charts or machine learning. It handles the same work as spreadsheets but at far larger scale and in repeatable code.
How do I install pandas?
Run pip install pandas in your terminal, or conda install pandas if you use Anaconda. Anaconda ships pandas pre-installed, so many beginners never install it manually. Once installed, you import it in your script with import pandas as pd.
What is the difference between a Series and a DataFrame?
A Series is a single labelled column of data, like one column from a spreadsheet. A DataFrame is a full table made of many Series that share the same row index. In practice you spend most of your time with DataFrames and reach into individual Series when you need one column.
Do I need to know NumPy before pandas?
No, you can start pandas without deep NumPy knowledge. Pandas is built on top of NumPy and borrows its array ideas, so a little NumPy helps later. Most beginners learn core pandas first and pick up NumPy alongside it.
Is pandas hard to learn for beginners?
Pandas is beginner-friendly if you already know a little Python and understand rows and columns from spreadsheets. The syntax is readable and most tasks take a line or two. The main learning curve is memorizing which method does what, which comes quickly with practice.

Want to Build Your Career in Data Analytics with AI?

Join CodeBegun and train with working industry engineers — Check the Data Analyst training details

Apply for Demo Class →
Siva Prasad Galaba
Founder, CodeBegun · Staff Engineer

Founder of CodeBegun. 15+ years building Java systems at companies like Crunchyroll. Teaches Java, Spring Boot and system design the way the industry actually works, and mentors students through projects, mock interviews and placement preparation.

Technically reviewed by CodeBegun Technical TeamLast reviewed 16 July 2026 LinkedIn
Chat with us