Creating and Inspecting Series and DataFrames
Now that you’ve been introduced to Pandas, it’s time to start creating real data structures.
In this lesson, you’ll learn how to build Series and DataFrames from Python lists and dictionaries.
These objects allow you to store, label, and organize data efficiently — and Pandas makes the process simple and intuitive.
Series
A Series is a one-dimensional labeled array — similar to a single column in a spreadsheet.
Below is an example of creating a Series from a list.
import pandas as pd # Create a Series of daily step counts steps = pd.Series([8000, 9200, 10200], name="Steps") print("Steps Series:", steps)
Series are useful for storing and manipulating single columns of data.
DataFrame
A DataFrame is a two-dimensional labeled table with rows and columns — much like a spreadsheet.
Below is an example of creating a DataFrame from a dictionary.
import pandas as pd # Create a Series of daily step counts steps = pd.Series([8000, 9200, 10200], name="Steps") # Create a DataFrame of sales records sales = pd.DataFrame({ "Product": ["Book", "Pen", "Notebook"], "Price": [12.99, 1.50, 4.75] }) print("Steps Series:", steps) print("Sales DataFrame:", sales)
DataFrames are useful for storing and manipulating multiple columns of data.
Lessons in this chapter · Taming Data with Pandas
- 1. Introduction to Pandas and DataFrames
- 2. Creating and Inspecting Series and DataFrames
- 3. Selecting Columns and Rows
- 4. Filtering with Boolean Conditions
- 5. Updating and Modifying Data
- 6. Anatomy of a DataFrame
- 7. Multiple-choice quiz
- 8. Handling Missing and Duplicate Data
- 9. Sorting, Ranking, and Reindexing
- 10. GroupBy and Aggregation Functions
- 11. Merging and Joining DataFrames
- 12. Descriptive Statistics and Value Counts
- 13. Working with Date and Time Columns
- 14. Fill-in-the-blank quiz
Which Pandas function is used to preview the first few rows of a DataFrame?
.describe()
.info()
.head()
.tail()
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help