1. Introduction to pandas
1.1 What is pandas?
Highlights & notes
Select lesson text to highlight it, or tap Add note.
Bookmarks
Bookmark a lesson to see it here.
pandas is a Python library for working with tables of data, like an Excel sheet you control with code. Data engineers use it to read files, clean messy values and summarise results in a few lines.
- A Series is one column: values with labels
- A DataFrame is a whole table: rows and named columns
- Each column of a DataFrame is a Series
pandas is imported with the short name pd: import pandas as pd. The code boxes on this site load pandas the first time you run them, which can take a few seconds.
Excel vs pandas
- Sheet → DataFrame
- Column → Series
- Row number → index
- A formula dragged down a column → one line of pandas that works on the whole column
Always start with import pandas as pd. Without it, Python doesn’t know what pd means and raises NameError.
How it fits together
- Raw CSV file
- pandas DataFrame
- Clean result
Step through the code
Python
import pandas as pdcities = pd.Series(["Noida", "Delhi", "Pune"])print(cities)print(len(cities))
Output
0 Noida 1 Delhi 2 Pune dtype: object 3
Practice in pandas ✓ Solved
Create a Series called prices with 120, 80 and 45, then print its length.
Expected output
3
Reference solution
import pandas as pd
prices = pd.Series([120, 80, 45])
print(len(prices))
Question 1 · Easy
What is a DataFrame?
Question 2 · Medium
What is one column of a DataFrame called?
Question 3 · Hard
You run pd.DataFrame(...) without import pandas as pd. What happens?
Key takeaways
pandas works with tables in Python. A Series is one column; a DataFrame is a whole table. Start with import pandas as pd.
Save your progress
Start free and your progress, code and notes stay saved. Free for 1 month, no card needed.
Start free Log in