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
pdalias. Writingpandas.DataFrame(...)works only if you imported the full name. Stick toimport pandas as pdand usepdeverywhere. - Confusing a Series with a DataFrame.
df["salary"]returns a Series (one column), whiledf[["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. Checkdtypesearly 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?
How do I install pandas?
What is the difference between a Series and a DataFrame?
Do I need to know NumPy before pandas?
Is pandas hard to learn for beginners?
Want to Build Your Career in Data Analytics with AI?
Join CodeBegun and train with working industry engineers — Check the Data Analyst training details

