Introduction

pandas is Python's most-used library for working with tabular data — spreadsheets and CSV files, but manipulated with code instead of a mouse. This course assumes you already know basic Python; if you're new to Python itself, start with the Python course first.

Series and DataFrame

pandas gives you two core data structures. A Series is a single labeled column of values — like one column of a spreadsheet. A DataFrame is a full table made of several Series sharing the same row labels — like the whole spreadsheet. Almost everything you do in pandas is building, slicing, or reshaping a DataFrame.

>>> a Series
import pandas as pd

prices = pd.Series([4.5, 2.0, 6.25, 1.75])
print(prices)
Output
0    4.50
1    2.00
2    6.25
3    1.75
dtype: float64

The left-hand column (0, 1, 2, 3) is the index — a label for each value, generated automatically here. Every Series and DataFrame in pandas has one, and you'll use it constantly to look values up.

Installing and importing

Install it once with pip install pandas. Every pandas file in this course starts the same way — import pandas as pd is such a strong convention that you'll rarely see it imported under any other name:

>>> a first DataFrame
import pandas as pd

data = {"name": ["Maya", "Sam", "Priya"], "score": [88, 92, 79]}
df = pd.DataFrame(data)
print(df)
Output
    name  score
0   Maya     88
1    Sam     92
2  Priya     79

A dictionary of lists becomes a DataFrame: each key is a column name, each list is that column's values. Notice pandas lined the columns up neatly and added the same auto-generated index you saw with the Series.

Note: printing a large DataFrame doesn't show every row — pandas truncates the middle with ... once a DataFrame gets long, and truncates wide DataFrames' columns the same way. That's a display setting, not a sign your data is missing; the real data is all still there.