What are Series and DataFrames in Pandas, and how are they different?
Updated Feb 20, 2026
Short answer
Pandas provides two core data structures: Series for one-dimensional labeled data and DataFrame for two-dimensional labeled data with rows and columns. A Series is like a single column, while a DataFrame is like a complete spreadsheet made of multiple Series objects.
Deep explanation
Series and DataFrames are the two fundamental data structures in Pandas. They are designed to make working with structured data easier by adding labels, powerful operations, and efficient handling of missing values.
What is a Series?
A Series is a one-dimensional array-like object that stores values with an associated index. Each value has a label, allowing you to access data by position or by name.
A Series contains:
- Data: the actual values, such as numbers, strings, or dates.
- Index: labels that identify each value.
- Data type: information about the kind of values stored.
Example:
import pandas as pd
sales = pd.Series( [120, 150, 170], index=["Monday", "Tuesday", "Wednesday"])
print(sales["Tuesday"])Here, sales is a Series. The values are sales numbers, and the index labels are days of the week.
What is a DataFrame?
A DataFrame is a two-dimensional table-like structure containing rows and columns. Each column in a DataFrame is actually a separate Series object sharing the same index.
A DataFrame contains:
- Multiple columns of data.
- Row indexes.
- Column names.
- Potentially different data types in different columns.
Example:
import pandas as pd
employees = pd.DataFrame( { "name": ["Ana", "Ben"], "salary": [50000, 60000] })
print(employees["salary"])The employees object is a DataFrame. Selecting the salary column returns a Series.
Remember: a DataFrame is essentially a collection of aligned Series objects.
Relationship between Series and DataFrame
The relationship can be visualized like this:
A DataFrame can be thought of as a container where each column is a Series. This design gives Pandas flexibility: you can analyze a single variable using a Series or work with a full dataset using a DataFrame.
Key Differences
| Feature | Series | DataFrame |
|---|---|---|
| Dimension | One-dimensional | Two-dimensional |
| Structure | Single labeled column | Table with rows and columns |
| Labels | Index only | Index plus column names |
| Common use | One variable or column | Complete datasets |
Why do both exist?
A Series is useful when you only need one stream of labeled data. For example, analyzing daily temperatures or a single stock price history.
A DataFrame is better when data has multiple related attributes. For example, customer data may include names, ages, locations, and purchase totals.
A good interview answer mentions that every DataFrame column is a Series, but a Series does not contain multiple columns.
Common operations
Both structures support similar operations because they share the same underlying design:
- Selecting data using labels.
- Filtering values.
- Applying functions.
- Handling missing values.
- Performing mathematical operations.
For example:
import pandas as pd
scores = pd.Series([80, 90, 70])
high_scores = scores[scores > 75]A DataFrame adds table operations such as selecting columns, joining datasets, and grouping rows.
⚠️ The choice is usually simple: use aSeriesfor one labeled variable and aDataFramefor a dataset with multiple variables.
Real-world example
Imagine a company analyzing online orders. A single list of order amounts can be stored as a Series, while the complete order history belongs in a DataFrame.
import pandas as pd
orders = pd.DataFrame( { "customer": ["Asha", "Raj"], "amount": [250, 400], "status": ["paid", "pending"] })
amounts = orders["amount"]Here, orders is a DataFrame containing the complete business record. The amounts variable is a Series extracted from one column for focused analysis, such as calculating averages or finding the highest order value.
In real projects, you will usually load data into a DataFrame first and then create Series objects by selecting columns.
Common mistakes
- * **Confusing dimensions** - A `Series` is not a smaller `DataFrame`
- it is a separate one-dimensional structure. Use the structure that matches the shape of your data.
- * **Ignoring indexes** - Pandas relies heavily on labels, so avoid assuming data is accessed only by numeric position.
- * **Thinking columns are lists** - DataFrame columns are `Series` objects with indexes and Pandas behavior, not plain Python lists.
- * **Using Series for tables** - Do not force multiple related variables into separate Series when a DataFrame represents the relationship better.
- * **Forgetting selection results** - Selecting one column from a DataFrame usually returns a Series, while selecting multiple columns returns another DataFrame.
Follow-up questions
- How can you create a Series and a DataFrame in Pandas?
- What happens when you select a single column from a DataFrame?
- How are indexes different between Series and DataFrames?
- When would you choose a Series over a DataFrame?
- Are DataFrames stored as collections of Series?