Introduction to Pandas
If NumPy is a powerful calculator, Pandas is a complete spreadsheet with programming capabilities. It's built on top of NumPy and provides labeled, structured data - exactly what we deal with in finance.
Pandas Series: Labeled Data
A Series is like a NumPy array but with labels (an index):
Loading Python Playground...
Adding Meaningful Labels
Loading Python Playground...
Pandas DataFrame: Your Financial Spreadsheet
A DataFrame is a table with rows and columns - the most important data structure for financial analysis:
Loading Python Playground...
Viewing Data
Loading Python Playground...
Accessing Columns
Loading Python Playground...
Adding New Columns
Loading Python Playground...
Practice: Create a Portfolio DataFrame
Loading Python Exercise...
Practice: Add Weight Column
Loading Python Exercise...
Key Takeaways
- Pandas Series = NumPy array + labels
- Pandas DataFrame = table with rows and columns
- Access columns with
df['ColumnName'] - Add columns with
df['NewColumn'] = calculation - Use
.head(),.tail(),.shapeto explore data - DataFrames make financial calculations intuitive
Next, we'll learn about filtering, sorting, and more DataFrame operations!

