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.
import pandas as pd prices = pd.Series([4.5, 2.0, 6.25, 1.75]) print(prices)
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:
import pandas as pd
data = {"name": ["Maya", "Sam", "Priya"], "score": [88, 92, 79]}
df = pd.DataFrame(data)
print(df)
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.
... 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.